subscribeEvent example


    protected $request;

    /** * Register shopware auth resource * create pre-dispatch hook to check backend permissions */
    public function install()
    {
        $this->subscribeEvent('Enlight_Bootstrap_InitResource_Auth', 'onInitResourceAuth');
        $this->subscribeEvent('Enlight_Controller_Action_PreDispatch', 'onPreDispatchBackend');
        $this->subscribeEvent('Enlight_Bootstrap_InitResource_BackendSession', 'onInitResourceBackendSession');

        $form = $this->Form();
        $parent = $this->Forms()->findOneBy(['name' => 'Core']);
        $form->setParent($parent);
        $form->setLabel('Backend');
        $form->setElement('select', 'backendLocales', [
            'store' => 'base.Locale',
            'label' => 'Auswählbare Sprachen',
            'value' => [1, 2],
            

            $menu = $categoryTree;
        }

        $categoryPath = $this->getCategoryPath($activeCategoryId);

        return $this->setActiveFlags($menu$categoryPath);
    }

    private function subscribeEvents(): void
    {
        $this->subscribeEvent(
            'Theme_Compiler_Collect_Plugin_Less',
            'onCollectLessFiles'
        );

        $this->subscribeEvent(
            'Theme_Compiler_Collect_Plugin_Javascript',
            'onCollectJavascriptFiles'
        );

        $this->subscribeEvent(
            'Enlight_Controller_Action_PostDispatchSecure_Frontend',
            
$this->Plugin()->getWidgets()->add($widget);
    }

    /** * {@inheritdoc} */
    public function subscribeEvent($event$listener = null, $position = null)
    {
        if ($listener === null && $event instanceof Enlight_Event_Handler) {
            $this->Collection()->Subscriber()->registerListener($event);
        } else {
            parent::subscribeEvent($event$listener$position);
        }

        return $this;
    }

    /** * Helper function to register a plugin controller. * * If the default event listener is used for the registration of a plugin controller, the following requirements must be fulfilled: * 1. The plugin directory must contain a 'Controllers' subdirectory. * 2. The 'Controllers' directory must contain a subdirectory which corresponds to the module (Frontend, Backend, Widgets or API) * 3. The controller must be filed in this module directory. * 4. The controller file must have the same name as the controller class. * * If all the requirements are fulfilled, the controller is registered automatically. * Additionally, the following plugin namespaces/directories are registered, if available: * 1. The 'Views' plugin directory is added as a template directory. * 2. The 'Snippets' plugin directory is added as a config directory. * 3. The 'Components' plugin directory is added as a component namespace. * * @example * <code> * public function install() { * $this->registerController('Frontend', 'Example1'); * return true; * } * </code> * * @param string $module - Possible values: Frontend, Backend, Widgets, Api * @param string $name - The name of the controller * @param string $listener - Name of the event listener function which will be called * * @throws RuntimeException * * @return $this */
private const CONFIG_NOTIFY_CAPTCHA = 'notificationCaptchaConfig';

    /** * Installation of plugin * Create-Events to include custom code on product detail page * Creates new cronjob "notification" * * @return bool */
    public function install()
    {
        $this->subscribeEvent(
            'Enlight_Controller_Action_PostDispatch_Frontend_Detail',
            'onPostDispatch'
        );
        $this->subscribeEvent(
            'Enlight_Controller_Action_Frontend_Detail_Notify',
            'onNotifyAction'
        );
        $this->subscribeEvent(
            'Enlight_Controller_Action_Frontend_Detail_NotifyConfirm',
            'onNotifyConfirmAction'
        );
        
$this->Path() . 'Components/'
        );

        return Enlight_Class::Instance('Shopware_Components_SeoIndex');
    }

    /** * Registers all required events for the similar shown articles function. */
    protected function subscribeSearchIndexEvents()
    {
        $this->subscribeEvent(
            'Enlight_Controller_Dispatcher_ControllerPath_Backend_SearchIndex',
            'getSearchIndexBackendController'
        );

        $this->createCronJob('Refresh search index', 'RefreshSearchIndex', 86400, true);
        $this->subscribeEvent('Shopware_CronJob_RefreshSearchIndex', 'refreshSearchIndex');
    }

    /** * Registers all required events for the also bought articles function. */
    


class Shopware_Plugins_Core_Cron_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
    public function install()
    {
        $this->subscribeEvent(
            'Enlight_Controller_Dispatcher_ControllerPath_Backend_Cron',
            'onGetControllerPath'
        );

        $this->createForm();

        return true;
    }

    /** * @return string */


class Shopware_Plugins_Core_CronStock_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
    public function install()
    {
        $this->subscribeEvent(
            'Shopware_CronJob_ArticleStock',
            'onRun'
        );

        return true;
    }

    public function onRun(Enlight_Components_Cron_EventArgs $args)
    {
        $sql = ' SELECT d.ordernumber, d.id, a.id as `articleID`, d.unitID, a.name, a.description, a.description_long, a.shippingtime, a.datum as `added`, a.topseller, a.keywords, a.taxID, a.supplierID, a.changetime as `changed`, d.id as `articledetailsID`, d.ordernumber, d.suppliernumber, d.kind, d.additionaltext, COALESCE(sai.impressions, 0) as impressions, d.sales, d.active, d.instock, d.stockmin, d.weight, d.position, at.attr1, at.attr2, at.attr3, at.attr4, at.attr5, at.attr6, at.attr7, at.attr8, at.attr9, at.attr10, at.attr11, at.attr12, at.attr13, at.attr14, at.attr15, at.attr16, at.attr17, at.attr18, at.attr19, at.attr20, s.name as supplier, u.unit, t.tax FROM s_articles a INNER JOIN s_articles_details as d INNER JOIN s_articles_attributes as at LEFT JOIN s_articles_supplier as s ON a.supplierID = s.id LEFT JOIN s_core_units as u ON d.unitID = u.id LEFT JOIN s_core_tax as t ON a.taxID = t.id LEFT JOIN ( SELECT articleId AS id, SUM(s.impressions) AS impressions FROM s_statistics_article_impression s GROUP BY articleId ) sai ON sai.id = a.id WHERE d.articleID = a.id AND d.id = at.articledetailsID AND stockmin > instock ';
return $this->Application()->Config()->get(
            'topSellerActive',
            true
        );
    }

    /** * Registers all required events for the similar shown articles function. */
    protected function subscribeSimilarShownEvents()
    {
        $this->subscribeEvent('Enlight_Controller_Dispatcher_ControllerPath_Backend_SimilarShown', 'getSimilarShownBackendController');
        $this->subscribeEvent('Enlight_Bootstrap_InitResource_SimilarShown', 'initSimilarShownResource');
        $this->subscribeEvent('Shopware_Plugins_LastArticles_ResetLastArticles', 'afterSimilarShownArticlesReset');
        $this->subscribeEvent('Shopware_Modules_Articles_Before_SetLastArticle', 'beforeSetLastArticle');

        $this->createCronJob('Similar shown article refresh', 'RefreshSimilarShown', 86400, true);
        $this->subscribeEvent('Shopware_CronJob_RefreshSimilarShown', 'refreshSimilarShown');
    }

    /** * Registers all required events for the also bought articles function. */
    


    /** * Install plugin method * * Registers the plugin start event. * * @return bool */
    public function install()
    {
        $this->subscribeEvent(
            'Enlight_Controller_Front_StartDispatch',
            'onStartDispatch'
        );

        return true;
    }

    /** * Loads the plugin before the dispatch. */
    public function onStartDispatch(Enlight_Event_EventArgs $args)
    {


use Shopware\Models\Config\Element;

class Shopware_Plugins_Frontend_TagCloud_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
    public function install()
    {
        $this->subscribeEvent(
            'Enlight_Controller_Action_PostDispatch',
            'onPostDispatch'
        );

        $this->addForm();
        $this->translateForm();

        return true;
    }

    /** * @return array */
use Shopware\Components\Model\ModelManager;
use Shopware\Components\ShopRegistrationServiceInterface;
use Shopware\Models\Customer\Group as CustomerGroup;
use Shopware\Models\Shop\Shop;
use Shopware\Models\Shop\Template;
use Symfony\Component\HttpFoundation\Cookie;

class Shopware_Plugins_Core_Router_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
    public function install()
    {
        $this->subscribeEvent(
            'Enlight_Controller_Front_RouteStartup',
            'onRouteStartup'
        );

        $this->subscribeEvent(
            'Enlight_Controller_Front_RouteShutdown',
            'onRouteShutdown'
        );

        return true;
    }

    

    protected $response;

    /** * @var bool */
    protected $isApiCall = false;

    public function install()
    {
        $this->subscribeEvent('Enlight_Controller_Front_DispatchLoopStartup', 'onDispatchLoopStartup');
        $this->subscribeEvent('Enlight_Controller_Front_PreDispatch', 'onFrontPreDispatch');
        $this->subscribeEvent('Enlight_Bootstrap_InitResource_Auth', 'onInitResourceAuth');

        return true;
    }

    public function getCapabilities()
    {
        return [
            'install' => false,
            'enable' => false,
            

class Shopware_Plugins_Core_System_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
    /** * Install plugin method * * @return bool */
    public function install()
    {
        $this->subscribeEvent(
            'Enlight_Bootstrap_InitResource_System',
            'onInitResourceSystem'
        );
        $this->subscribeEvent(
            'Enlight_Bootstrap_InitResource_Modules',
            'onInitResourceModules'
        );
        $this->subscribeEvent(
            'Enlight_Controller_Front_DispatchLoopShutdown',
            'onDispatchLoopShutdown'
        );

        
'label' => $this->getLabel(),
        ];
    }

    /** * Install the plugin. * * @return bool */
    public function install()
    {
        $this->subscribeEvent(
            'Enlight_Controller_Action_PreDispatch',
            'onPreDispatch'
        );

        $this->subscribeEvent(
            'Shopware_Plugins_HttpCache_InvalidateCacheId',
            'onInvalidateCacheId'
        );

        $this->subscribeEvent(
            'Shopware_Plugins_HttpCache_ClearCache',
            

class Shopware_Plugins_Frontend_CronRefresh_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
    /** * Defining Cronjob-Events * * @return bool */
    public function install()
    {
        $this->subscribeEvent('Shopware_CronJob_Clearing', 'onCronJobClearing');
        $this->subscribeEvent('Shopware_CronJob_Search', 'onCronJobSearch');

        return true;
    }

    /** * Clear s_emarketing_lastarticles / s_statistics_search / s_core_log in 30 days interval * Delete all entries older then 30 days. * To change this time - modify sql-queries * * @return array */
Home | Imprint | This part of the site doesn't use cookies.