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

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