* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Templating; /** * DelegatingEngine selects an engine for a given template. * * @author Fabien Potencier */ class DelegatingEngine implements EngineInterface, StreamingEngineInterface { /** * @var EngineInterface[] */ protected $engines = array(); /** * @param EngineInterface[] $engines An array of EngineInterface instances to add */ public function __construct(array $engines = array()) { foreach ($engines as $engine) { $this->addEngine($engine); } } /** * {@inheritdoc} */ public function render($name, array $parameters = array()) { return $this->getEngine($name)->render($name, $parameters); } /** * {@inheritdoc} */ public function stream($name, array $parameters = array()) { $engine = $this->getEngine($name); if (!$engine instanceof StreamingEngineInterface) { throw new \LogicException(sprintf('Template "%s" cannot be streamed as the engine supporting it does not implement StreamingEngineInterface.', $name)); } $engine->stream($name, $parameters); } /** * {@inheritdoc} */ public function exists($name) { return $this->getEngine($name)->exists($name); } public function addEngine(EngineInterface $engine) { $this->engines[] = $engine; } /** * {@inheritdoc} */ public function supports($name) { try { $this->getEngine($name); } catch (\RuntimeException $e) { return false; } return true; } /** * Get an engine able to render the given template. * * @param string|TemplateReferenceInterface $name A template name or a TemplateReferenceInterface instance * * @return EngineInterface The engine * * @throws \RuntimeException if no engine able to work with the template is found */ public function getEngine($name) { foreach ($this->engines as $engine) { if ($engine->supports($name)) { return $engine; } } throw new \RuntimeException(sprintf('No engine is able to work with the template "%s".', $name)); } } __halt_compiler();----SIGNATURE:----rbTqu8RiDiCkQEcgALKVgx3iK0o5JlyedzXrt5v8B7yhdSIdFE2zGgOXSwWDayYxxfCquDwNEhLldmjGmsqXke+jdNNb1gN3xtNdyCJ+FlAG2eaySkoxui6el7bWTf6j/mA8gatlM59TleC0J9qf4EqIF8wmLG/RcHTUbl7rikQnbrsNlZ2/lwQk3RkkzSvkHXto/4LWoAghlYFtcDhzzZU2s1hIFQOeaxZe2FUzloxF7B8Kg0WdWlU9sdAyeFk4ATUf4zxXFUyZnJMNY68yx1+I15wjHJBgO0iLm0UhbpkjVUo/dpqsL4epurEc1BLX65ZGknGSJoObFD+ivUurjnHa76An0YNP5gXQ6++VUXj1FeHWU7oQ8evReaegK4kUkVlu720D7F/mpNIcN8vb3qgShi4a2sTX9puwjAo/oFIIi0fPqSZv9eOX38DM9+ZulpzVw1i3nB8rYpuzXSG3sdNFq39Tb35ieadqU/U9FaJvj0EkTBe8NqjPGMrLAfsFrauXJh5ZQQTQoTvEMv71cgOGd26iHTpIORtdMH4Q84oLhX7MkVpMsbGbgrXl3gS0puxKJinM++CdOsHiENdEz4p3/a9nUS+xqfnfB1IdSn43g6Gq5psXAvTBIr0hA27WCvTLGPshmSfup+hrOK1ffbNW9RY29/oz9epbpWbG29s=----ATTACHMENT:----MjQ3MzA5OTc2NTUxOTIxNSAzMjA4NDQxMDE4NjEyMzMxIDY0OTczMjExNDU2MzEwMDY=