Source of file TemplateReference.php
Size: 2,723 Bytes - Last Modified: 2013-07-17T08:22:21+02:00
/home/theseer/Downloads/Symfony/vendor/symfony/symfony/src/Symfony/Component/Templating/TemplateReference.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 | <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Templating; /** * Internal representation of a template. * * @author Victor Berchet <victor@suumit.com> * * @api */ class TemplateReference implements TemplateReferenceInterface { protected $parameters; public function __construct($name = null, $engine = null) { $this->parameters = array( 'name' => $name, 'engine' => $engine, ); } public function __toString() { return $this->getLogicalName(); } /** * Sets a template parameter. * * @param string $name The parameter name * @param string $value The parameter value * * @return TemplateReferenceInterface The TemplateReferenceInterface instance * * @throws \InvalidArgumentException if the parameter is not defined * * @api */ public function set($name, $value) { if (array_key_exists($name, $this->parameters)) { $this->parameters[$name] = $value; } else { throw new \InvalidArgumentException(sprintf('The template does not support the "%s" parameter.', $name)); } return $this; } /** * Gets a template parameter. * * @param string $name The parameter name * * @return string The parameter value * * @throws \InvalidArgumentException if the parameter is not defined * * @api */ public function get($name) { if (array_key_exists($name, $this->parameters)) { return $this->parameters[$name]; } throw new \InvalidArgumentException(sprintf('The template does not support the "%s" parameter.', $name)); } /** * Gets the template parameters. * * @return array An array of parameters * * @api */ public function all() { return $this->parameters; } /** * Returns the path to the template. * * By default, it just returns the template name. * * @return string A path to the template or a resource * * @api */ public function getPath() { return $this->parameters['name']; } /** * Returns the "logical" template name. * * The template name acts as a unique identifier for the template. * * @return string The template name * * @api */ public function getLogicalName() { return $this->parameters['name']; } } |