loadActionButtonsForView example

$this->app1OrderDetailButtonId = Uuid::randomHex();
        $this->app1ProductDetailButtonId = Uuid::randomHex();
        $this->app1OrderListButtonId = Uuid::randomHex();
        $this->app2OrderDetailButtonId = Uuid::randomHex();
        $this->app3OrderDetailButtonId = Uuid::randomHex();
    }

    public function testLoadActionButtonsForView(): void
    {
        $this->registerActionButtons();

        $loadedActionButtons = $this->actionButtonLoader->loadActionButtonsForView('order', 'detail', $this->context);

        usort($loadedActionButtonsfn (array $a, array $b): int => $a['app'] <=> $b['app']);

        static::assertEquals([
            [
                'app' => 'App1',
                'id' => $this->app1OrderDetailButtonId,
                'label' => [
                    'en-GB' => 'Order Detail App1',
                ],
                'action' => 'orderDetailApp1',
                
private readonly ActionButtonLoader $actionButtonLoader,
        private readonly AppActionLoader $appActionFactory,
        private readonly Executor $executor,
        private readonly ModuleLoader $moduleLoader
    ) {
    }

    #[Route(path: 'api/app-system/action-button/{entity}/{view}', name: 'api.app_system.action_buttons', methods: ['GET'])]     public function getActionsPerView(string $entity, string $view, Context $context): Response
    {
        return new JsonResponse([
            'actions' => $this->actionButtonLoader->loadActionButtonsForView($entity$view$context),
        ]);
    }

    #[Route(path: 'api/app-system/action-button/run/{id}', name: 'api.app_system.action_button.run', methods: ['POST'], defaults: ['_acl' => ['app']])]     public function runAction(string $id, Request $request, Context $context): Response
    {
        $entityIds = $request->get('ids', []);

        $action = $this->appActionFactory->loadAppAction($id$entityIds$context);

        return $this->executor->execute($action$context);
    }
Home | Imprint | This part of the site doesn't use cookies.