Action example

$this->subscribeEvent(
            'Enlight_Plugins_ViewRenderer_FilterRender',
            'onFilterRender'
        );

        return true;
    }

    public function onFilterRender(Enlight_Event_EventArgs $args)
    {
        /** @var Enlight_Controller_Request_RequestHttp $request */
        $request = $args->getSubject()->Action()->Request();
        /** @var Enlight_Controller_Response_ResponseHttp $response */
        $response = $args->getSubject()->Action()->Response();

        $source = $args->getReturn();

        $headers = $response->getHeaders();
        foreach ($headers as $header) {
            if ($header['name'] === 'Content-Type' && str_starts_with($header['value'], 'application/javascript')) {
                $source = str_replace(["\r\n", "\r"], "\n", $source);
                $expressions = [
                    // Remove comments

    }

    /** * Listener method of the Enlight_Controller_Action_PostDispatch event. * If the current view instance has a template and the template should be rendered, * the template renders and the view template of the Enlight_Controller_Action * initials. */
    public function onPostDispatch(Enlight_Event_EventArgs $args)
    {
        if ($this->shouldRender() && $this->Action()->View()->hasTemplate()) {
            $this->render();
        }
        $this->setNoRender(false);
    }

    /** * Listener method of the Enlight_Controller_Action_PreDispatch event. * If the current view instance has a template and the template should be rendered, * the template is loaded by name. */
    public function onPreDispatch(Enlight_Event_EventArgs $args)
    {

            $this->resetResponse();
            $cookies = $this->Response()->getCookies();
            $this->resetRequest();
            $this->Request()->setCookies($cookies);

            return $this->dispatch($link);
        }

        /** @var Enlight_Controller_Plugins_ViewRenderer_Bootstrap $viewRenderer */
        $viewRenderer = $front->Plugins()->get('ViewRenderer');
        $this->_view = $viewRenderer->Action()->View();

        return $response;
    }

    /** * Reset all instances, resources and init the internal view, template and front properties * * @return void */
    public function reset()
    {
        
/** * Loads the script template, if not set. */
    public function onPreDispatch(Enlight_Event_EventArgs $args)
    {
        if (!$this->render) {
            return;
        }

        $this->render = false;

        if ($this->viewRenderer->Action()->View()->hasTemplate()
            || !$this->viewRenderer->shouldRender()
        ) {
            return;
        }

        $template = $this->getTemplateName();
        if ($template === null) {
            return;
        }

        $this->viewRenderer->Action()->View()->loadTemplate($template);

        
/** * Remove html-comments / whitespaces * * @return mixed|string */
    public function onFilterRender(Enlight_Event_EventArgs $args)
    {
        $source = $args->getReturn();
        $config = $this->get(Shopware_Components_Config::class);

        /** @var Enlight_Controller_Action $controller */
        $controller = $args->get('subject')->Action();

        if (!empty($config['minifyHtml']) && $this->canBeMinified($controller)) {
            $source = $this->get('shopware.components.template.html_minifier')->minify($source);
        }

        if (strpos($source, '<html') === false) {
            return $source;
        }

        // Remove comments         if (!empty($config['sSEOREMOVECOMMENTS'])) {
            
Home | Imprint | This part of the site doesn't use cookies.