/** * Constructor. */ public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, GlobalVariables $globals = null) { parent::__construct($parser, $container, $loader, $globals); /** * @todo move most of these to template helpers/existing globals */ $this->addGlobal('templateView', $this->container->get('templateView')); // find services tagged as view variables foreach ($container->get('containerTagService')->findTaggedServiceIds('zenmagick.http.view.variable') as $id => $args) { $key = null; foreach ($args as $elem) { foreach ($elem as $key => $value) { if ('key' == $key && $value) { $key = $value; break; } } } $obj = $this->container->get($id); if ($obj instanceof Toolbox) { foreach ($obj->getTools() as $name => $tool) { if ($tool instanceof ToolboxTool) { $tool->setView($this->container->get('defaultView')); } $this->addGlobal($name, $tool); } } $this->addGlobal($key, $obj); } // set all plugins if ($this->container->has('pluginService')) { // @todo inject this instead foreach ($this->container->get('pluginService')->getPluginsForContext() as $plugin) { $this->addGlobal($plugin->getId(), $plugin); } } }
/** * Constructor. * * @param TemplateNameParserInterface $parser A TemplateNameParserInterface instance * @param ContainerInterface $container A ContainerInterface instance * @param LoaderInterface $loader A LoaderInterface instance * @param Stopwatch $stopwatch A Stopwatch instance * @param GlobalVariables $globals A GlobalVariables instance */ public function __construct(TemplateNameParserInterface $parser, ContainerInterface $container, LoaderInterface $loader, Stopwatch $stopwatch, GlobalVariables $globals = null) { parent::__construct($parser, $container, $loader, $globals); $this->stopwatch = $stopwatch; }