src/Event/Subscriber/AdminSubscriber.php
private function getRedirectionUrl(
        AdminInterface $admin,
        ActionInterface $action,
        AdminConfiguration $configuration,
        Request $request
    ): string {
        if ('edit' === $action->getName()) {
            $routeName = RoutingLoader::generateRouteName(
                $admin->getName(),
                'list',
                $configuration->get('routing_name_pattern')
            );
            $url = $this->router->generate($routeName);

            return $url;
        }

        // When the create form is submitted, the user should be redirected to the edit action after saving the form
        // data
        if ('create' === $action->getName()) {
            $targetAction = 'list';
            $routeParameters = [];

            if (!$request->get('submit_and_redirect')) {
                $targetAction = 'edit';
                $routeParameters = [
                    'id' => $admin->getEntities()->first()->getId(),
                ];
            }
            $routeName = RoutingLoader::generateRouteName(
                $admin->getName(),
                $targetAction,
                $configuration->get('routing_name_pattern')
            );
            $url = $this->router->generate($routeName, $routeParameters);

            return $url;
        }

        if ('delete' === $action->getName()) {
            $routeName = RoutingLoader::generateRouteName(
                $admin->getName(),
                'list',
                $configuration->get('routing_name_pattern')
            );
            $url = $this->router->generate($routeName);

            return $url;
        }

        throw new Exception('Unable to generate an redirection url for the current action');
    }
private function getRedirectionUrl(
        AdminInterface $admin,
        ActionInterface $action,
        AdminConfiguration $configuration,
        Request $request
    ): string {
        if ('edit' === $action->getName()) {
            $routeName = RoutingLoader::generateRouteName(
                $admin->getName(),
                'list',
                $configuration->get('routing_name_pattern')
            );
            $url = $this->router->generate($routeName);

            return $url;
        }

        // When the create form is submitted, the user should be redirected to the edit action after saving the form
        // data
        if ('create' === $action->getName()) {
            $targetAction = 'list';
            $routeParameters = [];

            if (!$request->get('submit_and_redirect')) {
                $targetAction = 'edit';
                $routeParameters = [
                    'id' => $admin->getEntities()->first()->getId(),
                ];
            }
            $routeName = RoutingLoader::generateRouteName(
                $admin->getName(),
                $targetAction,
                $configuration->get('routing_name_pattern')
            );
            $url = $this->router->generate($routeName, $routeParameters);

            return $url;
        }

        if ('delete' === $action->getName()) {
            $routeName = RoutingLoader::generateRouteName(
                $admin->getName(),
                'list',
                $configuration->get('routing_name_pattern')
            );
            $url = $this->router->generate($routeName);

            return $url;
        }

        throw new Exception('Unable to generate an redirection url for the current action');
    }
private function getRedirectionUrl ( AdminInterface $ admin , ActionInterface $ action , AdminConfiguration $ configuration , Request $ request ) : string { if ( 'edit' === $ action -> getName ( ) ) { $ routeName = RoutingLoader :: generateRouteName ( $ admin -> getName ( ) , 'list' , $ configuration -> get ( 'routing_name_pattern' ) ) ; $ url = $ this -> router -> generate ( $ routeName ) ; return $ url ; } // When the create form is submitted, the user should be redirected to the edit action after saving the form // data if ( 'create' === $ action -> getName ( ) ) { $ targetAction = 'list' ; $ routeParameters = [ ] ; if ( ! $ request -> get ( 'submit_and_redirect' ) ) { $ targetAction = 'edit' ; $ routeParameters = [ 'id' => $ admin -> getEntities ( ) -> first ( ) -> getId ( ) , ] ; } $ routeName = RoutingLoader :: generateRouteName ( $ admin -> getName ( ) , $ targetAction , $ configuration -> get ( 'routing_name_pattern' ) ) ; $ url = $ this -> router -> generate ( $ routeName , $ routeParameters ) ; return $ url ; } if ( 'delete' === $ action -> getName ( ) ) { $ routeName = RoutingLoader :: generateRouteName ( $ admin -> getName ( ) , 'list' , $ configuration -> get ( 'routing_name_pattern' ) ) ; $ url = $ this -> router -> generate ( $ routeName ) ; return $ url ; } throw new Exception ( 'Unable to generate an redirection url for the current action' ) ; }
Return the url where the user should be redirected to. An exception will be thrown if no url can be generated.

@param AdminInterface     $admin
@param ActionInterface    $action
@param AdminConfiguration $configuration
@param Request            $request

@return string

@throws Exception
Return the url where the user should be redirected to . An exception will be thrown if no url can be generated .