* * 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:----lpRgYWbS6/5Ep/mdj5Ft8zqOIjaF/6fAZ/+vZpLYHk77xHfe/NWEuyk+9ia00UXSqszCTJu+wkH3EFAaGsPXixJdVNjIXm6LfCF68VNoKvdRUsArbdtyeV5yI0i1FpMHZV87YUHoGRH1LlMxV3Zly2KelFWTUN5sU3GuezDs/hopGG/elAi9+VR5Iofy8KaHmQEX6X8Smj3OKs35HdWf0ktx6kFtivQHc3KV7CjfEiPGTigAdPJ7HnBTCNacylPfqp9w7OO7noXVcw8DPQgOcd71HVUR/yspEbOm7gl0gLNc1CPdy4UElh4ifKbjd9vD5QyzK6/u6vYzLIhLd3SAWysNj2mzgLGHcSR98UI9UhUTx/mHDsUkTLzvnCVf1mkwawugZGNVAnUo5tgh3LmSl3jAvSvl/y4HFUHdj0nBskvzhIDRxOpqGiTsLc1B8Q9Vu+hTGX36P3zGPrmAkQ68x7fT0+zrVeuSmjHO8nYKipj2bgcp6zzY4sn3nNS3Eqk2lnJX4vbt8NE1cnDSXmMzltLdZi+emQ9nWfP3diqOcGUOMfTglyZEUyIoxvEv8+V7e3u2WQloZqZ7aclWU8LlAOhkIvhVt/7cvrIVP0/rlJEEsbXuF8cdhu5muICtGwUYWkTMp6IcDfhvWMgd57Qiolb3ShJCX8GYvHxffAulZMA=----ATTACHMENT:----Njg3NTE3NzI1OTI4NDM2MCAzMjAyNjMxNzg5ODQ2NTE4IDg3NDQ4OTQ3NDI2MTg1OTM=