Engine example

$mail = $this->getRepository()->find($id);
        if (!$mail instanceof Mail) {
            $this->View()->assign(['success' => false, 'message' => 'Mail not found']);

            return;
        }

        if (!($value = $this->Request()->getParam('value'))) {
            $this->View()->assign(['success' => false, 'message' => 'Value not found']);
        }

        $compiler = new Shopware_Components_StringCompiler($this->View()->Engine());

        $shop = $this->get('models')->getRepository(Shop::class)->getActiveDefault();
        $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        $compiler->setContext(array_merge($this->getDefaultMailContext($shop)$mail->getContext()));

        try {
            $template = $compiler->compileString($value);
        } catch (Enlight_Exception $e) {
            $this->View()->assign(['success' => false, 'message' => $e->getMessage()]);

            

        parent::setContainer($loader);

        $this->get('events')->addListener('Enlight_Controller_Plugin_ScriptRenderer_formatControllerName', static function D) {
            return 'ContentType';
        });
    }

    public function preDispatch(): void
    {
        parent::preDispatch();
        $this->View()->Engine()->setCompileId($this->View()->Engine()->getCompileId() . '_' . $this->Request()->getControllerName());
    }

    public function indexAction(): void
    {
        parent::indexAction();
        $this->View()->loadTemplate('backend/content_type/app.js');
    }

    public function postDispatch(): void
    {
        parent::postDispatch();

        
$userId = $params['userId'];
        $status = $params['status'];

        if (!$toMail || !$fromName || !$fromMail || !$subject || !$content || !$userId) {
            $this->View()->assign(['success' => false, 'message' => 'All required fields needs to be filled.']);

            return;
        }

        $content = preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $params['content']);

        $compiler = new Shopware_Components_StringCompiler($this->View()->Engine());
        $defaultContext = [
            'sConfig' => Shopware()->Config(),
        ];
        $compiler->setContext($defaultContext);

        // Send eMail to customer         $mail->IsHTML(false);
        $mail->From = $compiler->compileString($fromMail);
        $mail->FromName = $compiler->compileString($fromName);
        $mail->Subject = $compiler->compileString($subject);
        $mail->Body = $compiler->compileString($content);
        
/** * @param string $output Path to output file */
    private function generateExport($output)
    {
        $outputHandle = fopen($output, 'w');

        if (!\is_resource($outputHandle)) {
            throw new \RuntimeException(sprintf('Output file %s can not be opened', $outputHandle));
        }

        $this->export->sSmarty = $this->View()->Engine();
        $this->export->sInitSmarty();

        // Export the feed         $this->export->executeExport($outputHandle);
    }

    /** * initialize the base class sExport */
    private function prepareExport()
    {
        


    public function onRegisterControllerTemplate(Enlight_Controller_ActionEventArgs $args): void
    {
        $viewsDirectory = $this->pluginPath . '/Resources/views';

        $controller = $args->getSubject();

        try {
            $view = $controller->View();
            if ($view !== null) {
                $view->Template()->Engine()->addTemplateDir($viewsDirectory);
            }
        } catch (Enlight_Exception $ignored) {
        }
    }

    /** * @param string $baseDir resource base directory * @param string $type `css` or `js` * * @return array<string> */
    
Home | Imprint | This part of the site doesn't use cookies.