bundles/Factory/CartBundle/Classes/Traits/Controller/ControllerDispatchActionTrait.php line 29

Open in your IDE?
  1. <?php
  2. namespace Factory\CartBundle\Classes\Traits\Controller;
  3. use Symfony\Component\HttpFoundation\Request;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  6. trait ControllerDispatchActionTrait
  7. {
  8.     /**
  9.      * This function is used to call the right controller action since in static routes in Pimcore 10, you can't
  10.      * define action as a placeholder as controller and action are not entered as separate fields anymore
  11.      * @param Request $request
  12.      * @return Response
  13.      */
  14.     public function dispatchAction(Request $request)
  15.     {
  16.         $action $request->attributes->get('action');
  17.         $action str_replace(' '''ucwords(str_replace('-'' '$action)));
  18.         $actionMethod lcfirst($action) . 'Action';
  19.         if (!method_exists($this$actionMethod)) {
  20.             throw new NotFoundHttpException(sprintf('Action "%s" not found.'$actionMethod));
  21.         }
  22.         return $this->forward($this::class . '::' $actionMethod, [
  23.             'request' => $request
  24.         ]);
  25.     }
  26. }