* * 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:----CmseTLj+uiIJtojqe+4kUMLSsl0hL79So+oog+SNZ1QEsd7FtKZZA2ikWi953tN7hLEhtBZcUgw9m9boF5F5DrxxkvPCQ6nn4Ky317naExHW3Nm3evy4/WTDYO0zuExU72FhEHQisdoPPes2+T2xIzMXKj8I01rTDdI3pps6MxjBPiMJbjVlgDam7h8nlhbFCNhd2+lA8IA7F0vhO+Cns0ueN8NJ7DOWvFfTdQHkjl0bxnk/je8XmpxLo1BfBSGuEuda52iKUb2QtrOXlkWtRKp11ZUTNUafI9GLnHhn0x622yystkb0wJAJMSMGrUgl1J0StbsoCwh6OhBqhetzcM3GL9wGYUUll1MmXC6ruHFAPcZarf5UFRWCLw04REmWfIrrgcvpIxO634K6hj0sx9TcH3KOOle0w1kaOBsTMCCkadOws8JHX06VElyY4nfWsmfCNPz6Eug4pneXy+sl+4WXqOF/nhi5usmjHUqiFNLAxWZ+pgItRjaaTiEvGyGrCBB2wOmVhYewyTRuEqeezQln2JfdKWVvzvSIlRg7fMWeejFjfiQt235slkNt/oNH7EVqvXijOrgwQ+xNs3g4xmMM/Jhyw9mHJ/fBZs9stx6G31qi3QtSqXi+zGzOQS5sMKQz/CAwkcs9JonHG36fQibb7ElJwgt6A+Ak/F6Za4o=----ATTACHMENT:----NTE3NTE0ODk0MDI5OTU2NiA5NjMzODkyNDI1MDYzMzIyIDE4MjE5MTc0NTM0MDYwMzA=