vendor/shopware/core/Framework/App/Api/AppActionController.php line 74

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\App\Api;
  3. use Shopware\Core\Framework\App\ActionButton\ActionButtonLoader;
  4. use Shopware\Core\Framework\App\ActionButton\AppActionLoader;
  5. use Shopware\Core\Framework\App\ActionButton\Executor;
  6. use Shopware\Core\Framework\App\Manifest\ModuleLoader;
  7. use Shopware\Core\Framework\Context;
  8. use Shopware\Core\Framework\Routing\Annotation\Acl;
  9. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  10. use Shopware\Core\Framework\Routing\Annotation\Since;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\HttpFoundation\JsonResponse;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. /**
  17.  * @internal only for use by the app-system, will be considered internal from v6.4.0 onward
  18.  *
  19.  * @Route(defaults={"_routeScope"={"api"}})
  20.  */
  21. class AppActionController extends AbstractController
  22. {
  23.     private ActionButtonLoader $actionButtonLoader;
  24.     private Executor $executor;
  25.     private AppActionLoader $appActionFactory;
  26.     private ModuleLoader $moduleLoader;
  27.     public function __construct(
  28.         ActionButtonLoader $actionButtonLoader,
  29.         AppActionLoader $appActionFactory,
  30.         Executor $executor,
  31.         ModuleLoader $moduleLoader
  32.     ) {
  33.         $this->actionButtonLoader $actionButtonLoader;
  34.         $this->executor $executor;
  35.         $this->appActionFactory $appActionFactory;
  36.         $this->moduleLoader $moduleLoader;
  37.     }
  38.     /**
  39.      * @Since("6.3.3.0")
  40.      * @Route("api/app-system/action-button/{entity}/{view}", name="api.app_system.action_buttons", methods={"GET"})
  41.      */
  42.     public function getActionsPerView(string $entitystring $viewContext $context): Response
  43.     {
  44.         return new JsonResponse([
  45.             'actions' => $this->actionButtonLoader->loadActionButtonsForView($entity$view$context),
  46.         ]);
  47.     }
  48.     /**
  49.      * @Since("6.3.3.0")
  50.      * @Route("api/app-system/action-button/run/{id}", name="api.app_system.action_button.run", methods={"POST"}, defaults={"_acl"={"app"}})
  51.      */
  52.     public function runAction(string $idRequest $requestContext $context): Response
  53.     {
  54.         $entityIds $request->get('ids', []);
  55.         $action $this->appActionFactory->loadAppAction($id$entityIds$context);
  56.         return $this->executor->execute($action$context);
  57.     }
  58.     /**
  59.      * @Since("6.3.3.0")
  60.      * @Route("api/app-system/modules", name="api.app_system.modules", methods={"GET"})
  61.      */
  62.     public function getModules(Context $context): Response
  63.     {
  64.         return new JsonResponse(['modules' => $this->moduleLoader->loadModules($context)]);
  65.     }
  66. }