enableSecurity example

public function factory(
        Enlight_Event_EventManager $eventManager,
        Enlight_Components_Snippet_Resource $snippetResource,
        EscaperInterface $escaper,
        array $templateConfig,
        array $securityConfig,
        array $backendOptions
    ) {
        $template = Enlight_Class::Instance(Enlight_Template_Manager::class[null, $backendOptions]);
        \assert($template instanceof Enlight_Template_Manager);

        $template->enableSecurity(new Security($template$securityConfig));

        $template->setOptions($templateConfig);
        $template->setEventManager($eventManager);

        $template->registerResource('snippet', $snippetResource);
        /* @phpstan-ignore-next-line is handled by magic method `\Smarty_Internal_TemplateBase::__call` and will set the property `\Smarty::$default_resource_type` */
        $template->setDefaultResourceType('snippet');

        $template->registerPlugin(Smarty::PLUGIN_MODIFIER, 'escapeHtml', [$escaper, 'escapeHtml']);
        $template->registerPlugin(Smarty::PLUGIN_MODIFIER, 'escapeHtmlAttr', [$escaper, 'escapeHtmlAttr']);
        $template->registerPlugin(Smarty::PLUGIN_MODIFIER, 'escapeJs', [$escaper, 'escapeJs']);
        
Home | Imprint | This part of the site doesn't use cookies.