2011-02-10 17:20:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-02-10 17:20:44 +00:00
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
*/
|
|
|
|
class TemplateReference implements TemplateReferenceInterface
|
|
|
|
{
|
|
|
|
protected $parameters;
|
|
|
|
|
|
|
|
public function __construct($name = null, $engine = null)
|
|
|
|
{
|
|
|
|
$this->parameters = array(
|
|
|
|
'name' => $name,
|
|
|
|
'engine' => $engine,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __toString()
|
|
|
|
{
|
|
|
|
return json_encode($this->parameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function getSignature()
|
|
|
|
{
|
|
|
|
return md5(serialize($this->parameters));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function get($name)
|
|
|
|
{
|
|
|
|
if (array_key_exists($name, $this->parameters)) {
|
|
|
|
return $this->parameters[$name];
|
|
|
|
}
|
2011-02-27 17:29:20 +00:00
|
|
|
|
|
|
|
throw new \InvalidArgumentException(sprintf('The template does not support the "%s" parameter.', $name));
|
2011-02-10 17:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function all()
|
|
|
|
{
|
|
|
|
return $this->parameters;
|
|
|
|
}
|
|
|
|
|
2011-02-21 18:24:27 +00:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function getPath()
|
|
|
|
{
|
|
|
|
return $this->parameters['name'];
|
|
|
|
}
|
2011-04-08 09:31:47 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function getLogicalName()
|
|
|
|
{
|
|
|
|
return $this->parameters['name'];
|
|
|
|
}
|
2011-02-10 17:20:44 +00:00
|
|
|
}
|