registerPlugin example

if ($auth->hasIdentity()) {
            $identity = $auth->getIdentity();
            $this->aclRole = $identity->role;
        }

        /** @var Enlight_Template_Manager $engine */
        $engine = $container->get(Enlight_Template_Manager::class);
        $engine->unregisterPlugin(
            Smarty::PLUGIN_FUNCTION,
            'acl_is_allowed'
        );
        $engine->registerPlugin(
            Smarty::PLUGIN_FUNCTION,
            'acl_is_allowed',
            [$this, 'isAllowed']
        );
    }

    /** * @return string */
    public function getDefaultLocale()
    {
        
return parent::load($name$throwException);
        }

        $classname = $item->get('class');
        if (!class_exists($classname)) {
            $classname .= 'Dummy';
        }

        /** @var Enlight_Plugin_Bootstrap_Config $plugin */
        $plugin = new $classname($name$item);

        return parent::registerPlugin($plugin);
    }

    /** * Writes all registered plugins into the storage. * The subscriber and the registered plugins are converted to an array. * * @return Enlight_Plugin_Namespace_Config */
    public function write()
    {
        if (!$this->storage instanceof Enlight_Config) {
            
/** * @return void */
    public function sInitSmarty()
    {
        $this->sSYSTEM->sSMARTY->compile_id = 'export_' . $this->sFeedID;

        $this->sSYSTEM->sSMARTY->cache_lifetime = 0;
        $this->sSYSTEM->sSMARTY->debugging = false;
        $this->sSYSTEM->sSMARTY->caching = false;

        $this->sSmarty->registerPlugin('modifier', 'htmlentities', [$this, 'sHtmlEntities']);
        $this->sSmarty->registerPlugin('modifier', 'format', [$this, 'sFormatString']);
        $this->sSmarty->registerPlugin('modifier', 'escape', [$this, 'sEscapeString']);
        $this->sSmarty->registerPlugin('modifier', 'category', [$this, 'sGetArticleCategoryPath']);
        $this->sSmarty->registerPlugin('modifier', 'link', [$this, 'sGetArticleLink']);
        $this->sSmarty->registerPlugin('modifier', 'image', [$this, 'sGetImageLink']);
        $this->sSmarty->registerPlugin('modifier', 'articleImages', [$this, 'sGetArticleImageLinks']);
        $this->sSmarty->registerPlugin('modifier', 'shippingcost', [$this, 'sGetArticleShippingcost']);
        $this->sSmarty->registerPlugin('modifier', 'property', [$this, 'sGetArticleProperties']);

        $this->sSmarty->assign('sConfig', $this->config);
        $this->sSmarty->assign('shopData', $this->shopData);
        
/** * populate Source Object with meta data from Resource * * @param Smarty_Template_Source $source source object * @param Smarty_Internal_Template $_template template object * * @return void */
    public function populate(Smarty_Template_Source $source, ?Smarty_Internal_Template $_template = null)
    {
        if (!isset($source->smarty->registered_plugins[Smarty::PLUGIN_BLOCK]['snippet'])) {
            $source->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'snippet', [__CLASS__, 'compileSnippetBlock']);
        }
        if (!isset($source->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['snippet'])) {
            $source->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'snippet', [$this, 'compileSnippetModifier']);
        }
        $default_resource = $source->smarty->default_resource_type;
        $source->smarty->default_resource_type = 'file';
        parent::populate($source$_template);
        $source->smarty->default_resource_type = $default_resource;
    }

    /** * Compiles the given snippet block if the content parameter is filled. * * @param array<string, mixed> $params * @param string|null $content * * @return string */
throw new Exception(sprintf('Plugin "%s" is encrypted but the ionCube Loader extension is not installed', $name));
                    }

                    $plugin = $collection->get($name);
                    if ($plugin === null) {
                        $plugin = $collection->initPlugin($namenew Enlight_Config([
                            'source' => $source,
                            'path' => $dir->getPathname() . DIRECTORY_SEPARATOR,
                        ]));
                    }

                    $collection->registerPlugin($plugin$refreshDate);
                }
            }
        }
    }

    /** * @throws Exception * * @return string */
    public function getPluginPath(Plugin $plugin)
    {
class ExtensionLoaderTest extends TestCase
{
    use ExtensionBehaviour;
    use IntegrationTestBehaviour;

    private ExtensionLoader $extensionLoader;

    protected function setUp(): void
    {
        $this->extensionLoader = $this->getContainer()->get(ExtensionLoader::class);

        $this->registerPlugin(__DIR__ . '/../_fixtures/AppStoreTestPlugin');
        $this->installApp(__DIR__ . '/../_fixtures/TestApp');
    }

    protected function tearDown(): void
    {
        $this->removePlugin(__DIR__ . '/../_fixtures/AppStoreTestPlugin');
        $this->removeApp(__DIR__ . '/../_fixtures/TestApp');
    }

    public function testAppNotInstalledDetectedAsTheme(): void
    {
        
public $_version = self::SMARTY_VERSION;

    /** * Initialize new SmartyBC object * * @param array $options options to set during initialization, e.g. array( 'forceCompile' => false ) */
    public function __construct(array $options=array())
    {
        parent::__construct($options);
        // register {php} tag         $this->registerPlugin('block', 'php', 'smarty_php_tag');
    }

    /** * wrapper for assign_by_ref * * @param string $tpl_var the template variable name * @param mixed &$value the referenced value to assign */
    public function assign_by_ref($tpl_var, &$value)
    {
        $this->assignByRef($tpl_var$value);
    }

    public function baseSetup()
    {
        MemoryLimit::setMinimumMemoryLimit(1024 * 1024 * 512);
        @set_time_limit(0);

        $keys = isset($this->template->registered_plugins['function']) ? array_keys($this->template->registered_plugins['function']) : [];
        if (!\in_array('sCategoryPath', $keys)) {
            $this->template->registerPlugin(
                Smarty::PLUGIN_FUNCTION,
                'sCategoryPath',
                [$this, 'sSmartyCategoryPath']
            );
        }

        if (!\in_array('createSupplierPath', $keys)) {
            $this->template->registerPlugin(
                Smarty::PLUGIN_FUNCTION,
                'createSupplierPath',
                [$this, 'createSupplierPath']
            );
\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']);
        $template->registerPlugin(Smarty::PLUGIN_MODIFIER, 'escapeCss', [$escaper, 'escapeCss']);
        $template->registerPlugin(Smarty::PLUGIN_MODIFIER, 'escapeUrl', [$escaper, 'escapeUrl']);

        return $template;
    }
}


    /** * Registers a plugin in the collection. * * @param Enlight_Plugin_Bootstrap|Shopware_Components_Plugin_Bootstrap $plugin * * @return Enlight_Plugin_PluginManager|Shopware_Components_Plugin_Namespace */
    public function registerPlugin(Enlight_Plugin_Bootstrap $plugin, ?DateTimeInterface $refreshDate = null)
    {
        parent::registerPlugin($plugin);

        if ($refreshDate === null) {
            $refreshDate = new DateTimeImmutable();
        }

        if (!\is_string($plugin->getName())) {
            throw new RuntimeException('Plugin name not initialized correctly');
        }

        $info = $plugin->Info();
        $capabilities = $plugin->getCapabilities();
        
Home | Imprint | This part of the site doesn't use cookies.