registerListener example


        $requestStack = $this->createMock(RequestStack::class);
        $request = $this->createMock(Request::class);
        $requestStack->method('getCurrentRequest')->willReturn($request);

        $this->tokenStorage = new TokenStorage();
        $this->generator = new LogoutUrlGenerator($requestStack, null, $this->tokenStorage);
    }

    public function testGetLogoutPath()
    {
        $this->generator->registerListener('secured_area', '/logout', null, null);

        $this->assertSame('/logout', $this->generator->getLogoutPath('secured_area'));
    }

    public function testGetLogoutPathWithoutLogoutListenerRegisteredForKeyThrowsException()
    {
        $this->expectException(\InvalidArgumentException::class);
        $this->expectExceptionMessage('No LogoutListener found for firewall key "unregistered_key".');
        $this->generator->registerListener('secured_area', '/logout', null, null, null);

        $this->generator->getLogoutPath('unregistered_key');
    }

        if ($priority === 0) {
            $priority = null;
        }

        $handler = new \Enlight_Event_Handler_Default(
            $eventName,
            $listener,
            $priority
        );

        $this->registerListener($handler);

        return $this;
    }

    /** * Registers the given event handler and adds it to the internal listeners array. * If no event position is set in the event handler, the event handler will be added to the * end of the list. * * @return Enlight_Event_EventManager */
    

    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 */
        
public function __construct($options = null)
    {
        if (\is_array($options) && isset($options[0])) {
            foreach ($options as $listener) {
                if (!$listener instanceof Enlight_Event_Handler) {
                    $listener = new Enlight_Event_Handler_Default(
                        $listener['event'],
                        $listener['position'],
                        $listener['listener']
                    );
                }
                $this->registerListener($listener);
            }
        }
    }

    /** * Retrieves a list of listeners registered. * * @return array */
    public function getListeners()
    {
        
/** * 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 subscribeEvent($event$listener$position = null)
    {
        $namespace = $this->Collection();
        $handler = new Enlight_Event_Handler_Plugin(
            $event$namespace$this$listener$position
        );
        $namespace->Subscriber()->registerListener($handler);

        return $this;
    }

    /** * This function installs the plugin. * * @return bool */
    public function install()
    {
    }

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

    /** * Called from the Event Manager after the dispatch process * * @return void */
    public function onPostDispatch(Enlight_Event_EventArgs $args)
    {
        $subject = $args->get('subject');
        if (!$subject instanceof Enlight_Controller_Action) {
            
$widget->setPlugin($this->Plugin());

        $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 */

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

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

    /** * Loads the script template, if not set. */
    public function onPreDispatch(Enlight_Event_EventArgs $args)
    {
        if (!$this->render) {
            return;
        }

        


    /** * 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()
            
Home | Imprint | This part of the site doesn't use cookies.