Symfony\Component\Templating\PhpEngine::set PHP Метод

set() публичный Метод

Sets a helper.
public set ( Symfony\Component\Templating\Helper\HelperInterface $helper, string $alias = null )
$helper Symfony\Component\Templating\Helper\HelperInterface The helper instance
$alias string An alias
    public function set(HelperInterface $helper, $alias = null)
    {
        $this->helpers[$helper->getName()] = $helper;
        if (null !== $alias) {
            $this->helpers[$alias] = $helper;
        }

        $helper->setCharset($this->charset);
    }

Usage Example

 public function initPlugin()
 {
     $this->app[$this->getPluginName()] = function ($app) {
         $paths = $app->config('templating.paths') ?: [$app['dir.root'] . '/module/' . $app['app.module'] . '/template/%name%'];
         $basePath = $app->config('templating.basePath') ?: $app->request()->getBasePath() . '/assets';
         $loader = new FilesystemLoader($paths);
         $engine = new PhpEngine(new TemplateNameParser(), $loader);
         $engine->addGlobal('app', $app);
         $engine->set(new SlotsHelper());
         $engine->set(new AssetsHelper($basePath));
         $app->event()->emit('plugin.templating.after', [$app, $engine]);
         return $engine;
     };
 }
All Usage Examples Of Symfony\Component\Templating\PhpEngine::set