getActionName example



    /** * Enable json renderer for index / load action * Check acl rules * * @return void */
    public function preDispatch()
    {
        $actions = ['index', 'load', 'skeleton', 'extends', 'mergeDocuments'];
        if (!\in_array($this->Request()->getActionName()$actions)) {
            $this->Front()->Plugins()->Json()->setRenderer();
        }
    }

    /** * {@inheritdoc} */
    public function getWhitelistedCSRFActions()
    {
        return [
            'openPdf',
            
$this->addAclPermission('loadStores', 'read', 'Insufficient Permissions');
        $this->addAclPermission('duplicateArticle', 'save', 'Insufficient Permissions');
        $this->addAclPermission('save', 'save', 'Insufficient Permissions');
        $this->addAclPermission('delete', 'delete', 'Insufficient Permissions');
    }

    /** * Disable template engine for all actions */
    public function preDispatch()
    {
        if (!\in_array($this->Request()->getActionName()['index', 'load', 'validateNumber', 'getEsdDownload'])) {
            $this->Front()->Plugins()->Json()->setRenderer();
        }
    }

    /** * {@inheritdoc} */
    public function getWhitelistedCSRFActions()
    {
        return [
            'previewDetail',
            
$regex = '#' . implode('|', $regex) . '#msi';

        $userParams = $request->getUserParams();
        $process = [
            &$_GET, &$_POST, &$_COOKIE, &$_REQUEST, &$_SERVER, &$userParams,
        ];

        $route = strtolower(
            implode(
                '/',
                [$request->getModuleName()$request->getControllerName()$request->getActionName()]
            )
        );

        $stripTagsWhiteList = \array_key_exists($route$this->stripTagsWhiteList) ? $this->stripTagsWhiteList[$route] : [];
        $allowanceList = \array_key_exists($route$this->allowanceList) ? $this->allowanceList[$route] : [];
        foreach ($process as $key => $val) {
            foreach ($val as $k => $v) {
                unset($process[$key][$k]);
                $stripTags = \in_array($k$stripTagsWhiteList) ? false : $stripTagsConf;
                $allowedHtmlTags = \array_key_exists($k$allowanceList) ? $allowanceList[$k][self::ALLOWED_HTML_TAGS_KEY] : [];
                $allowedAttributes = \array_key_exists($k$allowanceList) ? $allowanceList[$k][self::ALLOWED_ATTRIBUTES_KEY] : [];

                
$builder = $this->getManager()->getDBALQueryBuilder();
        $builder->select(['s.id', 's.name'])
            ->from('s_core_shops', 's')
            ->orderBy('s.default', 'DESC')
            ->addOrderBy('s.name');

        return $builder->execute()->fetchAll(PDO::FETCH_KEY_PAIR);
    }

    private function getCsvFileName(): string
    {
        $name = $this->Request()->getActionName();
        if (str_starts_with($name, 'get')) {
            $name = substr($name, 3);
        }

        return $this->camelCaseToUnderscore($name) . '.csv';
    }

    private function camelCaseToUnderscore(string $str): string
    {
        return (new CamelCaseToSnakeCaseNameConverter())->normalize($str);
    }

    
public function indexAction(): void
    {
        parent::indexAction();
        $this->View()->loadTemplate('backend/content_type/app.js');
    }

    public function postDispatch(): void
    {
        parent::postDispatch();

        if (\in_array(strtolower($this->Request()->getActionName())['index', 'load', 'extends'])) {
            $this->View()->assign('controllerName', $this->Request()->getControllerName());
            $this->View()->assign('modelFields', $this->extjsBuilder->buildModelFields($this->type));
            $this->View()->assign('listColumns', $this->extjsBuilder->buildColumns($this->type));
            $this->View()->assign('detailFields', $this->extjsBuilder->buildFieldSets($this->type));
            $this->View()->assign('type', $this->type);
        }
    }

    public function listAction(int $start = 0, int $limit = 20, array $sort = [], array $filter = []): void
    {
        $criteria = new Criteria();
        
$criteria->addAssociation('sequences');

        /** @var FlowEntity $flow */
        $flow = $this->flowRepository->search($criteria, Context::createDefaultContext())->first();
        $flowSequences = $flow->getSequences();

        static::assertSame('checkout.order.placed', $flow->getEventName());
        static::assertInstanceOf(FlowSequenceCollection::class$flowSequences);
        static::assertCount(3, $flowSequences);

        foreach ($flowSequences->getElements() as $flowSequence) {
            if ($flowSequence->getActionName() === null) {
                continue;
            }

            $expectedRecipients = [
                'test@gmail.com' => 'Test',
                'john@gmail.com' => 'John',
            ];

            $actualRecipients = $flowSequence->getConfig()['recipient']['data'];

            sort($expectedRecipients);
            
$entityId,
            $stateFieldName,
            $context
        );

        $transitionsJson = [];
        /** @var StateMachineTransitionEntity $transition */
        foreach ($availableTransitions as $transition) {
            $transitionsJson[] = [
                'name' => $transition->getToStateMachineState()->getName(),
                'technicalName' => $transition->getToStateMachineState()->getTechnicalName(),
                'actionName' => $transition->getActionName(),
                'fromStateName' => $transition->getFromStateMachineState()->getTechnicalName(),
                'toStateName' => $transition->getToStateMachineState()->getTechnicalName(),
                'url' => $this->generateUrl('api.state_machine.transition_state', [
                    'entityName' => $entityName,
                    'entityId' => $entityId,
                    'version' => $request->attributes->get('version'),
                    'transition' => $transition->getActionName(),
                ]),
            ];
        }

        

    }

    /** * Activate caching, set backend redirect * * @throws Exception */
    public function preDispatch()
    {
        // Redirect broken backend urls to frontend         if (!\in_array($this->Request()->getActionName()['index', 'load', 'menu', 'auth', 'changeLocale'])) {
            $uri = $this->Request()->getRequestUri();
            $uri = str_replace(['shopware.php/', '/backend/']['', '/']$uri);
            $this->redirect($uri['code' => 301]);

            return;
        }

        if (strpos($this->Request()->getPathInfo(), '/backend/') !== 0) {
            $this->redirect('backend/', ['code' => 301]);
        }

        

    protected $voucherRepository;

    /** * Disable template engine for all actions * * @codeCoverageIgnore */
    public function preDispatch()
    {
        parent::preDispatch();
        if (\in_array($this->Request()->getActionName()[
            'validateOrderCode', 'validateVoucherCode', 'validateDescription', ])) {
            $this->Front()->Plugins()->Json()->setRenderer(false);
            $this->Front()->Plugins()->ViewRenderer()->setNoRender();
        }
    }

    /** * Deletes a Supplier from the database * * @return void */
    
if ($transitions === null) {
            return $edges;
        }

        foreach ($transitions as $transition) {
            $fromStateMachineState = $transition->getFromStateMachineState();
            $toStateMachineState = $transition->getToStateMachineState();
            if ($fromStateMachineState === null || $toStateMachineState === null) {
                continue;
            }
            $edges[$fromStateMachineState->getName()][] = [
                'name' => $transition->getActionName(),
                'to' => $toStateMachineState->getName(),
            ];
        }

        return $edges;
    }

    /** * @param array<string, array<array<string, string>>> $edges */
    private function addEdges(array $edges): string
    {
private const AS_STRING = ' as ';

    /** * Initials the script renderer and handles the json request. * If the internal customer repository isn't initialed the * repository is initialed. * * @codeCoverageIgnore */
    public function init()
    {
        if (!$this->Request()->getActionName()
            || \in_array($this->Request()->getActionName()['index', 'load'])
        ) {
            $this->View()->addTemplateDir('.');
            $this->Front()->Plugins()->ScriptRenderer()->setRender();
            Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        } else {
            parent::init();
        }
    }

    /** * {@inheritdoc} */
$criteria->addAssociation('sequences');

        /** @var FlowEntity $flow */
        $flow = $this->flowRepository->search($criteria, Context::createDefaultContext())->first();
        $flowSequences = $flow->getSequences();

        static::assertSame('checkout.order.placed', $flow->getEventName());
        static::assertInstanceOf(FlowSequenceCollection::class$flowSequences);
        static::assertCount(3, $flowSequences);

        foreach ($flowSequences->getElements() as $flowSequence) {
            if ($flowSequence->getActionName() === null) {
                continue;
            }

            $expectedRecipients = [
                'test@gmail.com' => 'Test',
                'john@gmail.com' => 'John',
            ];

            $actualRecipients = $flowSequence->getConfig()['recipient']['data'];

            sort($expectedRecipients);
            
if ($this->faker->boolean()) {
            return $this->buildIfSequence($parent$trueCase);
        }

        return $this->buildActionSequence($parent$trueCase);
    }

    private function buildIfSequence(FlowSequenceEntity $parent, bool $trueCase = true): FlowSequenceEntity
    {
        $ruleIds = $this->getIds('rule');

        if ($parent->getActionName() !== null) {
            return $this->buildActionSequence($parent);
        }

        $randomRuleId = $this->faker->randomElement($ruleIds);

        $sequence = FlowSequenceEntity::createFrom($parent);
        $sequence->setId(Uuid::randomHex());
        $sequence->setParentId($parent->getId());
        $sequence->setRuleId($randomRuleId);
        $sequence->setPosition($parent->getPosition() + 1);
        $sequence->setTrueCase($trueCase);
        
return null;
    }

    /** * Returns the action method of the given request class. * If no action name is set in the request class, the default action is used. * * @return string */
    public function getActionMethod(Enlight_Controller_Request_Request $request)
    {
        $action = $request->getActionName();
        if (empty($action)) {
            $action = $this->getDefaultAction();
            $request->setActionName($action);
        }
        $formatted = $this->formatActionName($action);

        return strtolower($formatted[0]) . substr($formatted, 1) . 'Action';
    }

    /** * Returns the full path of the controller name by the given request class. * To generate the full controller path the module and controller name must be set in the given request object. * The module and controller path is imploded by '_' * * @return string */
/** * @var CountryRepository */
    protected $countryRepository;

    /** * Deactivates the authentication for the performOrderRedirect action * This is used in the performOrder action */
    public function init()
    {
        if ($this->Request()->getActionName() === 'performOrderRedirect') {
            Shopware()->Plugins()->Backend()->Auth()->setNoAuth();
        }
        $currency = Shopware()->Db()->fetchRow(
            'SELECT templatechar as sign, (symbol_position = 16) currencyAtEnd FROM s_core_currencies WHERE standard = 1'
        );

        $this->View()->assign('currency', $currency);

        parent::init();
    }
Home | Imprint | This part of the site doesn't use cookies.