notifyUntil example


    private function doLoad($id$fallbackName = null, $invalidBehavior = self::NULL_ON_INVALID_REFERENCE)
    {
        $eventManager = parent::get('events');

        /** @var Enlight_Event_EventArgs|null $event */
        $event = $eventManager->notifyUntil(
            'Enlight_Bootstrap_InitResource_' . $id,
            ['subject' => $this]
        );

        if ($fallbackName !== null && !$event && $fallbackName !== $id) {
            $event = $eventManager->notifyUntil(
                'Enlight_Bootstrap_InitResource_' . $fallbackName,
                ['subject' => $this]
            );
        }

        
if (isset($variables['sBookingID'])) {
            $context['sBookingID'] = $variables['sBookingID'];
        }

        $context = $this->eventManager->filter(
            'Shopware_Modules_Order_SendMail_FilterContext',
            $context,
            ['subject' => $this]
        );

        $mail = null;
        if ($event = $this->eventManager->notifyUntil(
            'Shopware_Modules_Order_SendMail_Create',
            [
                'subject' => $this,
                'context' => $context,
                'variables' => $variables,
            ]
        )) {
            $mail = $event->getReturn();
        }

        if (!($mail instanceof Zend_Mail)) {
            

        $customerGroupKey = $this->request->getParam('sValidation');
        $customerGroupId = $this->get(Connection::class)->fetchColumn(
            'SELECT id FROM s_core_customergroups WHERE `groupkey` = ?',
            [$customerGroupKey]
        );

        if ($customerGroupKey && !$customerGroupId) {
            throw new Enlight_Exception('Invalid customergroup');
        }

        $event = Shopware()->Events()->notifyUntil(
            'Shopware_Controllers_Frontend_Register_CustomerGroupRegister',
            ['subject' => $this, 'sValidation' => $customerGroupId]
        );

        if ($event) {
            return $this->get(Shopware_Components_Config::class)->get('defaultCustomerGroup', 'EK');
        }

        return $customerGroupKey;
    }

    
$source = preg_replace(array_keys($expressions)array_values($expressions)$source);
        }

        return $source;
    }

    private function canBeMinified(Enlight_Controller_Action $controller): bool
    {
        /** @var Enlight_Event_EventManager $events */
        $events = $this->get('events');

        if ($event = $events->notifyUntil(__CLASS__ . '_canBeMinified', [
            'controller' => $controller,
            'subject' => $this,
        ])) {
            return $event->getReturn();
        }

        $contentType = $controller->Response()->headers->get('content-type', 'text/html');

        if (strpos($contentType, 'text/html') !== 0) {
            return false;
        }

        
if ($this->isInsideErrorHandlerLoop) {
            $exceptions = $response->getException();
            if (\count($exceptions) > $this->exceptionCountAtFirstEncounter) {
                // Exception thrown by error handler; tell the front controller to throw it                 $front->throwExceptions(true);
                throw array_pop($exceptions);
            }

            if (\is_array($exceptions)) {
                $last = array_pop($exceptions);

                if ($this->eventManager->notifyUntil('Shopware_Components_Error_Log', [
                    'exception' => $last,
                ])) {
                    return false;
                }

                // Make sure this is an Exception and also no minor one                 if ($last instanceof Exception
                    && !\in_array($last->getCode()[
                        Enlight_Controller_Exception::ActionNotFound,
                        Enlight_Controller_Exception::Controller_Dispatcher_Controller_Not_Found,
                        Enlight_Controller_Exception::Controller_Dispatcher_Controller_No_Route,
                        
$attributes[$formattedColumn] = ['ISTRUE', 'ISFALSE', 'ISNULL'];
                    break;
                case 'date':
                    $attributes[$formattedColumn] = ['>', '>=', '<', '<=', '=', 'ISNULL'];
                    break;
                case 'datetime':
                    $attributes[$formattedColumn] = ['>', '>=', '<', '<=', '=', 'ISNULL'];
                    break;
                default:
                    // Allow custom types. If not event handles the unknown type                     // an exception will be thrown                     if ($event = $this->getEventManager()->notifyUntil(
                        'SwagMultiEdit_Product_Grammar_generateAttributesFromColumns_Type_' . ucfirst(strtolower($type)),
                        [
                            'subject' => $this,
                            'type' => $type,
                            'mapping' => $mapping,
                        ]
                    )) {
                        $attributes[$formattedColumn] = $event->getReturn();
                    } else {
                        throw new RuntimeException(sprintf('Column with type %s was not configured, yet', $type));
                    }
            }


        try {
            $this->adapter->startJob($job);
            /** @var Enlight_Components_Cron_EventArgs $jobArgs */
            $jobArgs = new $this->eventArgsClass([
                'subject' => $this,
                'job' => $job,
            ]);
            $jobArgs->setReturn($job->getData());

            $jobArgs = $this->eventManager->notifyUntil(
                $job->getAction(),
                $jobArgs
            );

            if ($jobArgs !== null) {
                $job->setData($jobArgs->getReturn());
                $this->adapter->updateJob($job);
            }

            $this->endJob($job);
            $this->eventManager->notify('Shopware_CronJob_Finished_' . $job->getAction()[
                

    public function getDqlFromTokens($tokens)
    {
        $params = [];
        $newTokens = [];

        foreach ($tokens as $key => $token) {
            // Allow anyone to subscribe to any token and replace it with his own logic             // Also allows you to add own tokens             if ($event = $this->getEventManager()->notifyUntil(
                'SwagMultiEdit_Product_DqlHelper_getDqlFromTokens_Token_' . ucfirst(strtolower($token['type'])),
                [
                    'subject' => $this,
                    'currentToken' => $token,
                    'alltokens' => $tokens,
                    'processedTokens' => $newTokens,
                ]
            )
            ) {
                $return = $event->getReturn();
                if (!\is_array($return)) {
                    

    public function getControllerPath(Enlight_Controller_Request_Request $request)
    {
        $controllerName = $request->getControllerName();
        $controllerName = $this->formatControllerName($controllerName);
        $moduleName = $this->formatModuleName($this->curModule);
        $controllerId = $this->getControllerServiceId($moduleName$controllerName);
        $request->unsetAttribute('controllerId');

        if ($event = Shopware()->Events()->notifyUntil(
            'Enlight_Controller_Dispatcher_ControllerPath_' . $moduleName . self::CLASS_NAMESPACE_SEPARATOR . $controllerName,
            ['subject' => $this, 'request' => $request])
        ) {
            return $event->getReturn();
        }

        if ($controllerId) {
            $request->setAttribute('controllerId', $controllerId);

            return clone $this->container->get($controllerId);
        }

        
Shopware()->Events()->notify(
            __CLASS__ . '_PreDispatch_' . $this->controller_name,
            $args
        );

        $this->preDispatch();

        if ($this->Request()->isDispatched() && !$this->Response()->isRedirect()) {
            $action_name = $this->Front()->Dispatcher()->getFullActionName($this->Request());

            if (!$event = Shopware()->Events()->notifyUntil(__CLASS__ . '_' . $action_name$args)) {
                $this->$action(...$this->getActionArguments($action));
            }

            $this->postDispatch();
        }

        // Fire "Secure"-PostDispatch-Events only if:         // - Request is Dispatched         // - Response in no Exception         // - View has template         if ($this->Request()->isDispatched()
            


    /** * @param int|null $categoryId * * @throws Enlight_Exception * * @return ListingArray|false */
    public function sGetArticlesByCategory($categoryId = null, ?Criteria $criteria = null)
    {
        if (Shopware()->Events()->notifyUntil('Shopware_Modules_Articles_sGetArticlesByCategory_Start', [
            'subject' => $this,
            'id' => $categoryId,
        ])) {
            return false;
        }

        $context = $this->contextService->getShopContext();

        $request = Shopware()->Container()->get('front')->Request();
        if (!$request instanceof Enlight_Controller_Request_Request) {
            throw new RuntimeException('Required request not available');
        }
return parent::doRun($input$output);
    }

    /** * {@inheritdoc} */
    protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
    {
        $eventManager = $this->kernel->getContainer()->get('events');

        $event = $eventManager->notifyUntil('Shopware_Command_Before_Run', [
            'command' => $command,
            'input' => $input,
            'output' => $output,
        ]);

        if ($event) {
            return (int) $event->getReturn();
        }

        $exitCode = parent::doRunCommand($command$input$output);

        

    public function sLogin($ignoreAccountMode = false)
    {
        if ($this->eventManager->notifyUntil('Shopware_Modules_Admin_Login_Start', [
            'subject' => $this,
            'ignoreAccountMode' => $ignoreAccountMode,
            'post' => $this->front->Request()->getPost(),
        ])) {
            return false;
        }

        $sErrorFlag = null;
        $sErrorMessages = null;

        // If fields are not set, markup these fields
'articleID' => 0,
            'ordernumber' => $name,
            'quantity' => 1,
            'price' => $discount,
            'netprice' => $discountNet,
            'tax_rate' => $tax,
            'datum' => date('Y-m-d H:i:s'),
            'modus' => 3,
            'currencyFactor' => $this->sSYSTEM->sCurrency['factor'],
        ];

        $notifyUntilBeforeAdd = $this->eventManager->notifyUntil(
            'Shopware_Modules_Basket_BeforeAddOrderDiscount',
            [
                'subject' => $this,
                'discount' => $params,
            ]
        );

        if ($notifyUntilBeforeAdd) {
            return;
        }

        
if (str_starts_with($pathInfo, '/backend/') || str_starts_with($pathInfo, '/api/')) {
            return $pathInfo;
        }
        if ($context->getShopId() === null) { // only frontend             return $pathInfo;
        }

        $request = EnlightRequest::createFromGlobals();
        $request->setBaseUrl($context->getBaseUrl());
        $request->setPathInfo($pathInfo);

        $event = $this->eventManager->notifyUntil('Enlight_Controller_Router_Route', [
            'request' => $request,
            'context' => $context,
        ]);

        return $event !== null ? $event->getReturn() : false;
    }
}
Home | Imprint | This part of the site doesn't use cookies.