Revert "Reduce Engine constructor complexity."
This reverts commit e9d4af3bbe.
This commit is contained in:
+38
-25
@@ -50,23 +50,6 @@ class Mustache_Engine
|
|||||||
private $parser;
|
private $parser;
|
||||||
private $compiler;
|
private $compiler;
|
||||||
|
|
||||||
private static $optionProperties = array(
|
|
||||||
'template_class_prefix' => 'templateClassPrefix',
|
|
||||||
'cache_lambda_templates' => 'cacheLambdaTemplates',
|
|
||||||
'escape' => 'escape',
|
|
||||||
'entity_flags' => 'entityFlags',
|
|
||||||
'charset' => 'charset',
|
|
||||||
'strict_callables' => 'strictCallables',
|
|
||||||
);
|
|
||||||
|
|
||||||
private static $optionSetters = array(
|
|
||||||
'loader' => 'setLoader',
|
|
||||||
'partials_loader' => 'setPartialsLoader',
|
|
||||||
'partials' => 'setPartials',
|
|
||||||
'helpers' => 'setHelpers',
|
|
||||||
'logger' => 'setLogger',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mustache class constructor.
|
* Mustache class constructor.
|
||||||
*
|
*
|
||||||
@@ -135,6 +118,10 @@ class Mustache_Engine
|
|||||||
*/
|
*/
|
||||||
public function __construct(array $options = array())
|
public function __construct(array $options = array())
|
||||||
{
|
{
|
||||||
|
if (isset($options['template_class_prefix'])) {
|
||||||
|
$this->templateClassPrefix = $options['template_class_prefix'];
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($options['cache'])) {
|
if (isset($options['cache'])) {
|
||||||
$cache = $options['cache'];
|
$cache = $options['cache'];
|
||||||
|
|
||||||
@@ -146,22 +133,48 @@ class Mustache_Engine
|
|||||||
$this->setCache($cache);
|
$this->setCache($cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($options['cache_lambda_templates'])) {
|
||||||
|
$this->cacheLambdaTemplates = (bool) $options['cache_lambda_templates'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['loader'])) {
|
||||||
|
$this->setLoader($options['loader']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['partials_loader'])) {
|
||||||
|
$this->setPartialsLoader($options['partials_loader']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['partials'])) {
|
||||||
|
$this->setPartials($options['partials']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['helpers'])) {
|
||||||
|
$this->setHelpers($options['helpers']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($options['escape'])) {
|
if (isset($options['escape'])) {
|
||||||
if (!is_callable($options['escape'])) {
|
if (!is_callable($options['escape'])) {
|
||||||
throw new Mustache_Exception_InvalidArgumentException('Mustache Constructor "escape" option must be callable');
|
throw new Mustache_Exception_InvalidArgumentException('Mustache Constructor "escape" option must be callable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->escape = $options['escape'];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (self::$optionProperties as $name => $property) {
|
if (isset($options['entity_flags'])) {
|
||||||
if (isset($options[$name])) {
|
$this->entityFlags = $options['entity_flags'];
|
||||||
$this->$property = $options[$name];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (self::$optionSetters as $name => $setter) {
|
if (isset($options['charset'])) {
|
||||||
if (isset($options[$name])) {
|
$this->charset = $options['charset'];
|
||||||
$this->$setter($options[$name]);
|
}
|
||||||
}
|
|
||||||
|
if (isset($options['logger'])) {
|
||||||
|
$this->setLogger($options['logger']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['strict_callables'])) {
|
||||||
|
$this->strictCallables = $options['strict_callables'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user