Events example

$context = $this->get(ContextServiceInterface::class)->createShopContext($shopId);

            $this->RewriteTable()->sCreateRewriteTableCategories();
            $this->RewriteTable()->sCreateRewriteTableCampaigns();
            $this->RewriteTable()->sCreateRewriteTableContent();
            $this->RewriteTable()->sCreateRewriteTableBlog(null, null, $context);
            $this->RewriteTable()->createManufacturerUrls($context);
            $this->RewriteTable()->sCreateRewriteTableStatic();
            $this->RewriteTable()->createContentTypeUrls($context);

            Shopware()->Events()->notify(
                'Shopware_CronJob_RefreshSeoIndex_CreateRewriteTable',
                [
                    'shopContext' => $context,
                    'cachedTime' => $currentTime,
                ]
            );
        }

        return true;
    }

    
$mailSubject = $this->replaceVariables($content['email_subject']);

        $receivers = explode(',', $content['email']);
        $receivers = array_map('trim', $receivers);

        $mail->setFrom(Shopware()->Config()->get('Mail'));
        $mail->clearRecipients();
        $mail->addTo($receivers);
        $mail->setBodyText($mailBody);
        $mail->setSubject($mailSubject);

        $mail = Shopware()->Events()->filter('Shopware_Controllers_Frontend_Forms_commitForm_Mail', $mail['subject' => $this]);

        if (!$mail->send()) {
            throw new Enlight_Exception('Could not send mail');
        }
    }

    /** * @param int $formId * * @throws Enlight_Exception * @throws Exception * * @return array */

        $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;
    }

    


    /** * @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');
        }
$id = $this->getPluginId($bootstrap->getName());
        $plugin = $em->find(Plugin::class$id);

        $newInfo = $bootstrap->getInfo();
        $newInfo = new Enlight_Config($newInfo, true);
        unset($newInfo->source);
        $bootstrap->Info()->merge($newInfo);
        $this->registerPlugin($bootstrap);

        $this->setConfig($bootstrap->getName()$bootstrap->Config());

        $this->Application()->Events()->notify(
            'Shopware_Plugin_PreInstall',
            [
                'subject' => $this,
                'plugin' => $bootstrap,
            ]
        );

        $result = $bootstrap->install();

        $success = \is_bool($result) ? $result : !empty($result['success']);
        if ($success) {
            
Shopware_Components_Modules $moduleManager = null,
        ?sSystem $systemModule = null,
        ?ContextServiceInterface $contextService = null,
        ?EmailValidatorInterface $emailValidator = null,
        ?Shopware_Components_Translation $translationComponent = null,
        ?Connection $connection = null,
        ?OptInLoginServiceInterface $optInLoginService = null,
        ?CSRFTokenValidator $csrfTokenValidator = null,
        ?ShippingCostServiceInterface $shippingCostService = null
    ) {
        $this->db = $db ?: Shopware()->Db();
        $this->eventManager = $eventManager ?: Shopware()->Events();
        $this->config = $config ?: Shopware()->Config();
        $this->session = $session ?: Shopware()->Session();
        $this->front = $front ?: Shopware()->Front();
        $this->passwordEncoder = $passwordEncoder ?: Shopware()->PasswordEncoder();
        $this->snippetManager = $snippetManager ?: Shopware()->Snippets();
        $this->moduleManager = $moduleManager ?: Shopware()->Modules();
        $this->sSYSTEM = $systemModule ?: Shopware()->System();

        $mainShop = Shopware()->Shop()->getMain() !== null ? Shopware()->Shop()->getMain() : Shopware()->Shop();
        $this->scopedRegistration = $mainShop->getCustomerScope();

        


    /** * Loads the plugin before the dispatch. */
    public function onStartDispatch(Enlight_Event_EventArgs $args)
    {
        $event = new Enlight_Event_Handler_Default(
            'Enlight_Controller_Front_PreDispatch',
            [$this, 'onPreDispatch']
        );
        Shopware()->Events()->registerListener($event);
    }

    /** * Checks the url / the request and passes it around if necessary. */
    public function onPreDispatch(Enlight_Controller_EventArgs $args)
    {
        $request = $args->getRequest();
        $response = $args->getResponse();

        if ($response->isException()
            
'salt_len' => 22,
        ];
    }

    /** * @throws Enlight_Event_Exception */
    public function onInitResourcePasswordEncoder(Enlight_Event_EventArgs $args): Manager
    {
        // Get a list of all available hashes         /** @var array<PasswordEncoderInterface> $availableHasher */
        $availableHasher = Shopware()->Events()->filter(
            'Shopware_Components_Password_Manager_AddEncoder',
            [],
            ['subject' => $this]
        );

        $passwordManager = new Manager(
            $this->Application()->Config()
        );

        foreach ($availableHasher as $encoder) {
            $passwordManager->addEncoder($encoder);
        }
$valueData['value'] = $this->prepareValue($elementData$valueData['value']);

            $value = new Value();
            $value->setElement($element);
            $value->setShop($shop);
            $value->setValue($valueData['value']);
            $values[$shop->getId()] = $value;
        }

        $this->beforeSaveElement($elementData);

        $values = Shopware()->Events()->filter(
            'Shopware_Controllers_Backend_Config_Before_Save_Config_Element',
            $values,
            [
                'subject' => $this,
                'element' => $element,
            ]
        );

        $element->setValues(new ArrayCollection($values));

        $modelManager->flush($element);

        

    public function initController(
        Enlight_Controller_Request_RequestHttp $request,
        Enlight_Controller_Response_ResponseHttp $response
    ) {
        $this->setRequest($request)->setResponse($response);

        $this->controller_name = $this->Front()->Dispatcher()->getFullControllerName($this->Request());

        Shopware()->Events()->notify(
            __CLASS__ . '_Init',
            ['subject' => $this, 'request' => $this->Request(), 'response' => $this->Response()]
        );
        Shopware()->Events()->notify(
            __CLASS__ . '_Init_' . $this->controller_name,
            ['subject' => $this, 'request' => $this->Request(), 'response' => $this->Response()]
        );

        if (method_exists($this, 'init')) {
            $this->init();
        }
    }
$sql,
            [
                Shopware()->Shop()->get('parentID'),
                Shopware()->Shop()->getId(),
                $shopFallbackId,
                $lastUpdate,
            ]
        );

        $result = $this->mapArticleTranslationObjectData($result);

        $result = Shopware()->Events()->filter(
            'Shopware_Modules_RewriteTable_sCreateRewriteTableArticles_filterArticles',
            $result,
            [
                'shop' => Shopware()->Shop()->getId(),
            ]
        );

        foreach ($result as $row) {
            $this->data->assign('sArticle', $row);
            $path = $this->template->fetch('string:' . $routerProductTemplate$this->data);
            $path = $this->sCleanupPath($path);

            

    public function init()
    {
        if ($this->Collection() === null) {
            return;
        }
        $event = new Enlight_Event_Handler_Default('Enlight_Controller_Action_PreDispatch', [
            $this, 'onPreDispatch',
        ]);
        $this->Application()->Events()->registerListener($event);
    }

    /** * Called from the event manager before the dispatch process. * Parse the json input data, when it was activated. * * @return void */
    public function onPreDispatch(Enlight_Event_EventArgs $args)
    {
        /** @var Enlight_Controller_Action $subject */
        
/** * Do http caching jobs * * @return void */
    public function onPreDispatch(Enlight_Controller_ActionEventArgs $args)
    {
        $this->action = $args->getSubject();
        $this->request = $args->getRequest();
        $this->response = $args->getResponse();

        $this->Application()->Events()->registerListener(
            new Enlight_Event_Handler_Default(
                'Enlight_Controller_Action_PostDispatch',
                [$this, 'onPostDispatch'],
                // Must be positioned before ViewRender Plugin so the ESI renderer can be registered before the template is rendered                 399
            )
        );
    }

    public function renderEsiTag(Enlight_Controller_Request_RequestHttp $request, array $params): ?string
    {
        

    public function send($transport = null)
    {
        Shopware()->Events()->notify(
            'Enlight_Components_Mail_Send',
            [
                'mail' => $this,
                'transport' => $transport,
            ]
        );

        if (!$this->getMessageId()) {
            $this->setMessageId();
        }

        
Enlight_Event_EventManager $eventManager = null,
        ?Shopware_Components_Snippet_Manager $snippetManager = null,
        ?Shopware_Components_Config $config = null,
        ?Enlight_Components_Session_Namespace $session = null,
        ?Enlight_Controller_Front $front = null,
        ?Shopware_Components_Modules $moduleManager = null,
        ?sSystem $systemModule = null,
        ?ContextServiceInterface $contextService = null,
        ?AdditionalTextServiceInterface $additionalTextService = null
    ) {
        $this->db = $db ?: Shopware()->Db();
        $this->eventManager = $eventManager ?: Shopware()->Events();
        $this->snippetManager = $snippetManager ?: Shopware()->Snippets();
        $this->config = $config ?: Shopware()->Config();
        $this->session = $session ?: Shopware()->Session();
        $this->front = $front ?: Shopware()->Front();
        $this->moduleManager = $moduleManager ?: Shopware()->Modules();
        $this->sSYSTEM = $systemModule ?: Shopware()->System();

        $this->contextService = $contextService;
        $this->additionalTextService = $additionalTextService;
        $this->connection = Shopware()->Container()->get(Connection::class);

        
Home | Imprint | This part of the site doesn't use cookies.