getActionId example

private readonly RouterInterface $router,
        private readonly RequestStack $requestStack,
        private readonly KernelInterface $kernel
    ) {
    }

    public function execute(AppAction $action, Context $context): Response
    {
        try {
            $this->shopIdProvider->getShopId();
        } catch (AppUrlChangeDetectedException $e) {
            throw AppException::actionButtonProcessException($action->getActionId()$e->getMessage()$e);
        }

        $payload = $action->asPayload();
        $payload['meta'] = [
            'timestamp' => (new \DateTime())->getTimestamp(),
            'reference' => Uuid::randomHex(),
            'language' => $context->getLanguageId(),
        ];

        $appSecret = $action->getAppSecret();

        
public function supports(string $actionType): bool
    {
        return $actionType === OpenModalResponse::ACTION_TYPE;
    }

    /** * @param array<mixed> $payload */
    public function create(AppAction $action, array $payload, Context $context): ActionButtonResponse
    {
        $this->validate($payload$action->getActionId());

        $appSecret = $action->getAppSecret();
        if ($appSecret) {
            $payload['iframeUrl'] = (string) $this->signer->signUri($payload['iframeUrl']$appSecret$context);
        }

        $response = new OpenModalResponse();
        $response->assign($payload);

        return $response;
    }

    
public function supports(string $actionType): bool
    {
        return $actionType === OpenNewTabResponse::ACTION_TYPE;
    }

    /** * @param array<mixed> $payload */
    public function create(AppAction $action, array $payload, Context $context): ActionButtonResponse
    {
        $this->validate($payload$action->getActionId());

        $appSecret = $action->getAppSecret();
        if ($appSecret) {
            $payload['redirectUrl'] = (string) $this->signer->signUri($payload['redirectUrl']$appSecret$context);
        }

        $response = new OpenNewTabResponse();
        $response->assign($payload);

        return $response;
    }

    
/** * @param array<mixed> $payload */
    public function createFromResponse(AppAction $action, string $actionType, array $payload, Context $context): ActionButtonResponse
    {
        foreach ($this->factories as $factory) {
            if ($factory->supports($actionType)) {
                return $factory->create($action$payload$context);
            }
        }

        throw AppException::actionButtonProcessException($action->getActionId()sprintf('No factory found for action type "%s"', $actionType));
    }
}
Home | Imprint | This part of the site doesn't use cookies.