|
@@ -21,6 +21,8 @@ use Symfony\Component\Templating\Loader\LoaderInterface;
|
|
|
* PhpEngine is an engine able to render PHP templates.
|
|
|
*
|
|
|
* @author Fabien Potencier <fabien@symfony.com>
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
{
|
|
@@ -70,6 +72,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
*
|
|
|
* @throws \InvalidArgumentException if the template does not exist
|
|
|
* @throws \RuntimeException if the template cannot be rendered
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function render($name, array $parameters = array())
|
|
|
{
|
|
@@ -105,6 +109,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* @param mixed $name A template name or a TemplateReferenceInterface instance
|
|
|
*
|
|
|
* @return Boolean true if the template exists, false otherwise
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function exists($name)
|
|
|
{
|
|
@@ -123,6 +129,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* @param mixed $name A template name or a TemplateReferenceInterface instance
|
|
|
*
|
|
|
* @return Boolean true if this class supports the given resource, false otherwise
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function supports($name)
|
|
|
{
|
|
@@ -169,6 +177,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* @return mixed The helper value
|
|
|
*
|
|
|
* @throws \InvalidArgumentException if the helper is not defined
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function offsetGet($name)
|
|
|
{
|
|
@@ -181,6 +191,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* @param string $name The helper name
|
|
|
*
|
|
|
* @return Boolean true if the helper is defined, false otherwise
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function offsetExists($name)
|
|
|
{
|
|
@@ -192,6 +204,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
*
|
|
|
* @param HelperInterface $name The helper instance
|
|
|
* @param string $value An alias
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function offsetSet($name, $value)
|
|
|
{
|
|
@@ -202,6 +216,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* Removes a helper.
|
|
|
*
|
|
|
* @param string $name The helper name
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function offsetUnset($name)
|
|
|
{
|
|
@@ -210,6 +226,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
|
|
|
/**
|
|
|
* @param Helper[] $helpers An array of helper
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function addHelpers(array $helpers)
|
|
|
{
|
|
@@ -222,6 +240,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* Sets the helpers.
|
|
|
*
|
|
|
* @params Helper[] $helpers An array of helper
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function setHelpers(array $helpers)
|
|
|
{
|
|
@@ -234,6 +254,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
*
|
|
|
* @param HelperInterface $helper The helper instance
|
|
|
* @param string $alias An alias
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function set(HelperInterface $helper, $alias = null)
|
|
|
{
|
|
@@ -251,6 +273,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* @param string $name The helper name
|
|
|
*
|
|
|
* @return Boolean true if the helper is defined, false otherwise
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function has($name)
|
|
|
{
|
|
@@ -265,6 +289,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* @return HelperInterface The helper instance
|
|
|
*
|
|
|
* @throws \InvalidArgumentException if the helper is not defined
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function get($name)
|
|
|
{
|
|
@@ -279,6 +305,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* Decorates the current template with another one.
|
|
|
*
|
|
|
* @param string $template The decorator logical name
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function extend($template)
|
|
|
{
|
|
@@ -292,6 +320,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* @param string $context The context name
|
|
|
*
|
|
|
* @return string The escaped value
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function escape($value, $context = 'html')
|
|
|
{
|
|
@@ -302,6 +332,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* Sets the charset to use.
|
|
|
*
|
|
|
* @param string $charset The charset
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function setCharset($charset)
|
|
|
{
|
|
@@ -312,6 +344,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* Gets the current charset.
|
|
|
*
|
|
|
* @return string The current charset
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function getCharset()
|
|
|
{
|
|
@@ -323,6 +357,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
*
|
|
|
* @param string $context The escaper context (html, js, ...)
|
|
|
* @param mixed $escaper A PHP callable
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function setEscaper($context, $escaper)
|
|
|
{
|
|
@@ -335,6 +371,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* @param string $context The context name
|
|
|
*
|
|
|
* @return mixed $escaper A PHP callable
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function getEscaper($context)
|
|
|
{
|
|
@@ -348,6 +386,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
/**
|
|
|
* @param string $name
|
|
|
* @param mixed $value
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function addGlobal($name, $value)
|
|
|
{
|
|
@@ -358,6 +398,8 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
|
|
* Returns the assigned globals.
|
|
|
*
|
|
|
* @return array
|
|
|
+ *
|
|
|
+ * @api
|
|
|
*/
|
|
|
public function getGlobals()
|
|
|
{
|