hasTemplate example

/** * 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);

        
/** * Optimize Sourcecode / Apply SEO rules */
    public function onPostDispatch(Enlight_Controller_ActionEventArgs $args)
    {
        $request = $args->getSubject()->Request();
        $response = $args->getSubject()->Response();
        $view = $args->getSubject()->View();

        if (!$request->isDispatched() || $response->isException()
            || $request->getModuleName() !== 'frontend'
            || !$view->hasTemplate()
        ) {
            return;
        }

        $config = $this->get(Shopware_Components_Config::class);

        /** @var QueryAliasMapper $mapper */
        $mapper = $this->get(QueryAliasMapper::class);

        $controllerBlacklist = preg_replace('#\s#', '', $config['sSEOVIEWPORTBLACKLIST']);
        $controllerBlacklist = explode(',', $controllerBlacklist);

        

    public function onPostDispatch(Enlight_Event_EventArgs $args)
    {
        $request = $args->getSubject()->Request();
        $response = $args->getSubject()->Response();

        /** @var Enlight_View_Default $view */
        $view = $args->getSubject()->View();

        if (!$request->isDispatched() || $response->isException()
            || $request->getModuleName() !== 'frontend'
            || !$view->hasTemplate()
        ) {
            return;
        }

        $view->assign('baseUrl', $request->getBaseUrl() . $request->getPathInfo());

        $shop = Shopware()->Shop();
        $view->assign('Controller', $args->getSubject()->Request()->getControllerName());

        $view->assign('sBasketQuantity', $view->getAssign('sBasketQuantity') ?: 0);
        $view->assign('sBasketAmount', $view->getAssign('sBasketAmount') ?: 0);
        
/** * On post dispatch we try to find affected articleIds displayed during this request * * @return void */
    public function onPostDispatch(Enlight_Controller_ActionEventArgs $args)
    {
        $view = $args->getSubject()->View();
        if (!$this->request->isDispatched()
            || $this->response->isException()
            || !$view->hasTemplate()
        ) {
            return;
        }

        if (!$this->hasSurrogateEsiCapability($this->request)) {
            return;
        }

        if ($this->request->getModuleName() !== 'frontend' && $this->request->getModuleName() !== 'widgets') {
            return;
        }

        


            $this->postDispatch();
        }

        // Fire "Secure"-PostDispatch-Events only if:         // - Request is Dispatched         // - Response in no Exception         // - View has template         if ($this->Request()->isDispatched()
            && !$this->Response()->isException()
            && $this->View()->hasTemplate()
        ) {
            Shopware()->Events()->notify(
                __CLASS__ . '_PostDispatchSecure_' . $this->controller_name,
                $args
            );

            Shopware()->Events()->notify(
                __CLASS__ . '_PostDispatchSecure_' . $moduleName,
                $args
            );

            

    public function reset()
    {
        $app = Shopware();

        $this->resetRequest();
        $this->resetResponse();

        // Force the assignments to be cleared. Needed for some test cases         if ($this->_view && $this->_view->hasTemplate()) {
            $this->_view->clearAssign();
        }

        $this->_view = null;
        $this->_template = null;
        $this->_front = null;

        $app->Plugins()->reset();
        $app->Events()->reset();

        $container = Shopware()->Container();

        

    }

    /** * 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)
    {

    }

    /** * @throws Exception */
    public function onDispatch(Enlight_Event_EventArgs $args)
    {
        /** @var Enlight_Controller_Action $controller */
        $controller = $args->get('subject');

        if (!$controller->View()->hasTemplate()) {
            return;
        }

        /** @var Shop $shop */
        $shop = $this->container->get('shop');

        $inheritance = $this->container->get('theme_inheritance');

        $templateManager = $this->container->get('template');
        $templateManager->addPluginsDir(
            $inheritance->getSmartyDirectories($shop->getTemplate())
        );
$locale = $this->getCurrentLocale();
        $container->get('locale')->setLocale($locale->toString());
        $container->get('snippets')->setLocale($locale);
        $template = $container->get(Enlight_Template_Manager::class);
        $baseHash = $this->request->getScheme() . '://'
                  . $this->request->getHttpHost()
                  . $this->request->getBaseUrl() . '?'
                  . $revision;
        $baseHash = substr(sha1($baseHash), 0, 5);
        $template->setCompileId('backend_' . $locale->toString() . '_' . $baseHash);

        if ($this->action !== null && $this->action->View()->hasTemplate()) {
            $this->action->View()->Template()->setCompileId($template->getCompileId());
        }
    }

    /** * Loads current user's locale or, if none exists, the default fallback * * @throws Exception * * @return Locale */
    
Home | Imprint | This part of the site doesn't use cookies.