src/Core/Framework/App/Api/AppActionController.php line 29

  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 Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. use Symfony\Component\HttpFoundation\JsonResponse;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. /**
  15.  * @internal only for use by the app-system, will be considered internal from v6.4.0 onward
  16.  */
  17. #[Route(defaults: ['_routeScope' => ['api']])]
  18. #[Package('core')]
  19. class AppActionController extends AbstractController
  20. {
  21.     public function __construct(private readonly ActionButtonLoader $actionButtonLoader, private readonly AppActionLoader $appActionFactory, private readonly Executor $executor, private readonly ModuleLoader $moduleLoader)
  22.     {
  23.     }
  24.     #[Route(path'api/app-system/action-button/{entity}/{view}'name'api.app_system.action_buttons'methods: ['GET'])]
  25.     public function getActionsPerView(string $entitystring $viewContext $context): Response
  26.     {
  27.         return new JsonResponse([
  28.             'actions' => $this->actionButtonLoader->loadActionButtonsForView($entity$view$context),
  29.         ]);
  30.     }
  31.     #[Route(path'api/app-system/action-button/run/{id}'name'api.app_system.action_button.run'methods: ['POST'], defaults: ['_acl' => ['app']])]
  32.     public function runAction(string $idRequest $requestContext $context): Response
  33.     {
  34.         $entityIds $request->get('ids', []);
  35.         $action $this->appActionFactory->loadAppAction($id$entityIds$context);
  36.         return $this->executor->execute($action$context);
  37.     }
  38.     #[Route(path'api/app-system/modules'name'api.app_system.modules'methods: ['GET'])]
  39.     public function getModules(Context $context): Response
  40.     {
  41.         return new JsonResponse(['modules' => $this->moduleLoader->loadModules($context)]);
  42.     }
  43. }