notify example


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

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

        
/** * Executes this context by calling the 'before' hooks, 'replace' hooks and 'after' hooks in that order and * returning the args' return value. */
    public function execute()
    {
        // Save this context in the proxy         $proxy = $this->args->getSubject();
        $proxy->__pushHookExecutionContext($this->args->getMethod()$this);

        // Before hooks         $this->hookManager->getEventManager()->notify(
            $this->getHookEventName(Enlight_Hook_HookHandler::TypeBefore),
            $this->args
        );

        // Replace hooks and/or original method         $this->args->setProcessed(false);
        $returnValue = $this->executeReplaceChain($this->args->getArgs());
        $this->args->setReturn($returnValue);
        $this->args->setProcessed(true);

        // After hooks
$this->loadThemeConfig();

        $this->View()->assign([
            'sArticles' => $products,
            'pageIndex' => (int) $this->Request()->getParam('sPage'),
            'productBoxLayout' => $boxLayout,
            'sCategoryCurrent' => $categoryId,
            'sCategoryContent' => $this->container->get('modules')->Categories()->sGetCategoryContent($categoryId),
        ]);

        $this->container->get('events')->notify('Shopware_Controllers_Widgets_Listing_fetchListing_preFetch', [
            'result' => $result,
            'subject' => $this,
        ]);
    }

    private function preparePagination(ProductSearchResult $result): void
    {
        $sPerPage = (int) $this->Request()->getParam('sPerPage');

        if ($sPerPage <= 0) {
            $sPerPage = 1;
        }
$this->policy = $policy;
    }

    public function send(Notification $notification, RecipientInterface ...$recipients): void
    {
        if (!$recipients) {
            $recipients = [new NoRecipient()];
        }

        foreach ($recipients as $recipient) {
            foreach ($this->getChannels($notification$recipient) as $channel => $transportName) {
                $channel->notify($notification$recipient$transportName);
            }
        }
    }

    public function addAdminRecipient(RecipientInterface $recipient): void
    {
        $this->adminRecipients[] = $recipient;
    }

    /** * @return RecipientInterface[] */
$criteria = $this->storeFrontCriteriaFactory->createBaseCriteria([$category]$context);
        $criteria->limit($sLimitChart);

        $criteria->addSorting(new PopularitySorting(SortingInterface::SORT_DESC));

        $criteria->setFetchCount(false);

        $result = $this->searchService->search($criteria$context);
        $products = $this->legacyStructConverter->convertListProductStructList($result->getProducts());

        Shopware()->Events()->notify(
            'Shopware_Modules_Articles_GetArticleCharts',
            ['subject' => $this, 'category' => $category, 'articles' => $products]
        );

        return $products;
    }

    /** * Check if a product has an instant download * * @deprecated in 5.5, this function will be removed in 5.7 without replacement * * @param int $id s_articles.id * @param int $detailsID s_articles_details.id * @param bool $realtime * * @return bool */
parent::__construct();
        $this->type = $type;
    }

    public function indexAction(int $p = 1): void
    {
        $criteria = new Criteria();
        $criteria->offset = ($p - 1) * self::LIMIT;
        $criteria->limit = self::LIMIT;
        $criteria->sort = [['property' => 'id', 'direction' => 'DESC']];

        $this->get('events')->notify(sprintf('Content_Type_Frontend_Criteria_Creation_%s', $this->type->getInternalName())[
            'subject' => $this,
            'criteria' => $criteria,
        ]);

        $result = $this->repository->findAll($criteria);

        $this->View()->assign('sPage', $p);
        $this->View()->assign('pages', ceil($result->total / self::LIMIT));
        $this->View()->assign('sItems', $result->items);
        $this->View()->assign('sTotal', $result->total);
        $this->View()->assign('sBreadcrumb', $this->getBreadcrumb());
    }
$entityManager->flush();

        // As of Shopware 4.1.3 clearing the cache via event is possible. As this is quite slow, however,         // this function is optional and disabled by default.         $clearCache = $this->getConfig()->getByNamespace('SwagMultiEdit', 'clearCache', false);
        if (!$clearCache) {
            return;
        }

        // Notify event - you might want register for this in order to clear the cache?         foreach ($this->getDqlHelper()->getIdForForeignEntity('article', $detailIds) as $productId) {
            $this->getDqlHelper()->getEventManager()->notify(
                'Shopware_Plugins_HttpCache_InvalidateCacheId',
                ['subject' => $this, 'cacheId' => 'a' . $productId]
            );
        }
    }

    /** * Batch processes a given queue * * @param int $queueId * * @throws RuntimeException * * @return array{totalCount: int, remaining: int, done: bool, processed: int} */
$requests[] = new Request('GET', $url$guzzleConfig);
        }

        $events = $this->eventManager;

        $pool = new Pool(
            $this->guzzleClient,
            $requests,
            [
                'concurrency' => $concurrentRequests,
                'rejected' => function D$reason) use ($shopId$events) {
                    $events->notify('Shopware_Components_CacheWarmer_ErrorOccured');
                    $this->logger->warning(
                        'Warm up http-cache error with shopId ' . $shopId . ' ' . $reason
                    );
                },
            ]
        );

        $pool->promise()->wait();
    }

    private function getMainShopId($shopId)
    {
/** * Removes entries from s_emarketing_lastarticles which are older than allowed by the configuration */
    private function cleanupLastProducts()
    {
        if (Random::getInteger(0, 100) === 0) {
            $time = (int) $this->container->get(Shopware_Components_Config::class)->get('lastarticles_time', 15);

            $sql = 'DELETE FROM s_emarketing_lastarticles WHERE `time` < DATE_SUB(CONCAT_WS(" ", CURDATE(), ?), INTERVAL ? DAY)';
            $this->container->get(\Doctrine\DBAL\Connection::class)->executeQuery($sql['00:00:00', $time]);

            $this->container->get('events')->notify('Shopware_Plugins_LastArticles_ResetLastArticles', ['subject' => $this]);
        }
    }

    /** * Creates a new s_emarketing_lastarticles entry for the passed article id. * * @param int $productId */
    private function setLastProductById($productId)
    {
        $sessionId = $this->container->get('session')->get('sessionId');

        
$values,
            [
                'subject' => $this,
                'element' => $element,
            ]
        );

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

        $modelManager->flush($element);

        Shopware()->Events()->notify('Shopware_Controllers_Backend_Config_After_Save_Config_Element', [
            'subject' => $this,
            'element' => $element,
        ]);
    }

    private function getFallbackLocaleId(int $currentLocaleId): int
    {
        if ($currentLocaleId === 1) {
            return 1;
        }

        

    public function dispatch()
    {
        if (!$this->getParam('noViewRenderer')) {
            $this->Plugins()->load('ViewRenderer');
        }

        $eventArgs = new Enlight_Controller_EventArgs([
            'subject' => $this,
        ]);

        $this->eventManager->notify(
            'Enlight_Controller_Front_StartDispatch',
            $eventArgs
        );

        if (!$this->router) {
            $this->setRouter(Router::class);
        }
        if (!$this->dispatcher) {
            $this->setDispatcher('Enlight_Controller_Dispatcher_Default');
        }

        

                    $definition->getImportDirectory(),
                ]
            );
        }

        // Allows to add own configurations for the current compile step.         if ($definition->getConfig()) {
            $this->compiler->setVariables($definition->getConfig());
        }

        $this->eventManager->notify(
            'Theme_Compiler_Compile_Less',
            [
                'shop' => $shop,
                'less' => $definition,
            ]
        );

        // Need to iterate files, to generate source map if configured.         foreach ($definition->getFiles() as $file) {
            if (!file_exists($file)) {
                continue;
            }

    public function installPlugin(Plugin $plugin)
    {
        $pluginBootstrap = $this->getPluginByName($plugin->getName());

        $context = new InstallContext($plugin$this->release->getVersion()$plugin->getVersion());

        $this->requirementValidator->validate($pluginBootstrap->getPath() . '/plugin.xml', $this->release->getVersion());

        $this->events->notify(PluginEvent::PRE_INSTALL, new PrePluginInstallEvent($context$pluginBootstrap));
        $this->installResources($pluginBootstrap$plugin);

        // Makes sure the version is updated in the db after a re-installation         if ($plugin->getUpdateVersion() && $this->hasInfoNewerVersion($plugin->getUpdateVersion()$plugin->getVersion())) {
            $plugin->setVersion($plugin->getUpdateVersion());
        }

        $this->em->flush($plugin);

        $this->applyMigrations($pluginBootstrap, AbstractPluginMigration::MODUS_INSTALL);

        
$this->createThemeDirectory($data['template']);

        $this->generateThemePhp($data$parent);

        $directory = $this->getThemeDirectory($data['template']);
        $this->generateStructure(
            $this->structure,
            $directory
        );

        $this->eventManager->notify('Theme_Generator_Structure_Generated', [
            'data' => $data,
            'directory' => $directory,
        ]);

        $this->movePreviewImage(
            $this->getThemeDirectory($data['template'])
        );
    }

    /** * @param string $directory */
$this->logger->error(sprintf('Could not synchronize theme. "%s" instance for theme "%s" not found', Template::class$theme->getName()));

            return;
        }

        // static main container which generated for each theme configuration.         $container = new TabContainer('main_container');

        // inject the inheritance config container.         $this->injectConfig($theme$container);

        $this->eventManager->notify('Theme_Configurator_Container_Injected', [
            'theme' => $theme,
            'template' => $template,
            'container' => $container,
        ]);

        $theme->createConfig($container);

        $this->validateConfig($container);

        $this->eventManager->notify('Theme_Configurator_Theme_Config_Created', [
            'theme' => $theme,
            
Home | Imprint | This part of the site doesn't use cookies.