2013-06-29 11:07:10 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package phpBB3
|
|
|
|
* @copyright (c) 2013 phpBB Group
|
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-09-10 14:01:09 +02:00
|
|
|
namespace phpbb\template\twig;
|
|
|
|
|
2013-06-29 11:07:10 -05:00
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
if (!defined('IN_PHPBB'))
|
|
|
|
{
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class holds all DEFINE variables from the current page load
|
|
|
|
*/
|
2013-09-10 14:01:09 +02:00
|
|
|
class definition
|
2013-06-29 11:07:10 -05:00
|
|
|
{
|
|
|
|
/** @var array **/
|
|
|
|
protected $definitions = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a DEFINE'd variable
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
* @return mixed Null if not found
|
|
|
|
*/
|
|
|
|
public function __call($name, $arguments)
|
|
|
|
{
|
|
|
|
return (isset($this->definitions[$name])) ? $this->definitions[$name] : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DEFINE a variable
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
* @param mixed $value
|
2013-09-10 14:01:09 +02:00
|
|
|
* @return \phpbb\template\twig\definition
|
2013-06-29 11:07:10 -05:00
|
|
|
*/
|
|
|
|
public function set($name, $value)
|
|
|
|
{
|
|
|
|
$this->definitions[$name] = $value;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2013-07-02 10:13:16 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Append to a variable
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
* @param string $value
|
2013-09-10 14:01:09 +02:00
|
|
|
* @return \phpbb\template\twig\definition
|
2013-07-02 10:13:16 -05:00
|
|
|
*/
|
|
|
|
public function append($name, $value)
|
|
|
|
{
|
|
|
|
if (!isset($this->definitions[$name]))
|
|
|
|
{
|
|
|
|
$this->definitions[$name] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->definitions[$name] .= $value;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2013-06-29 11:07:10 -05:00
|
|
|
}
|