Skip to content
Permalink
Browse files

Fix handling of parameters and add twig-debug parameter

  • Loading branch information...
mvriel committed Sep 2, 2013
1 parent ca127ee commit 8de4b962c6184735ec4bfd1fbe43196611e256d8
@@ -274,6 +274,12 @@ protected function addExtensionsFromTemplateConfiguration(
ProjectDescriptor $project,
\Twig_Environment $twigEnvironment
) {
$isDebug = $transformation->getParameter('twig-debug', 'false');
if ($isDebug == 'true') {
$twigEnvironment->enableDebug();
$twigEnvironment->addExtension(new \Twig_Extension_Debug());
}
/** @var \SimpleXMLElement $extension */
foreach ((array) $transformation->getParameter('twig-extension', array()) as $extension) {
$extension = (string) $extension;
@@ -12,6 +12,7 @@
namespace phpDocumentor\Transformer;
use JMS\Serializer\Annotation as Serializer;
use phpDocumentor\Transformer\Template\Parameter;
/**
* Model representing a template.
@@ -53,10 +54,17 @@ class Template implements \ArrayAccess, \Countable, \Iterator
/**
* @Serializer\XmlList(entry = "transformation")
* @Serializer\Type("array<phpDocumentor\Transformer\Transformation>")
* @var Transformation
* @var Transformation[]
*/
protected $transformations = array();
/**
* @Serializer\XmlKeyValuePairs
* @Serializer\Type("array")
* @var string[]
*/
protected $parameters = array();
/**
* Initializes this object with a name and optionally with contents.
*
@@ -309,4 +317,31 @@ public function current()
{
return current($this->transformations);
}
/**
* Returns the parameters associated with this template.
*
* @return \phpDocumentor\Transformer\Template\Parameter[]
*/
public function getParameters()
{
return $this->parameters;
}
public function setParameter($key, $value)
{
$this->parameters[$key] = $value;
}
/**
* Pushes the parameters of this template into the transformations.
*
* @return void
*/
public function propagateParameters()
{
foreach ($this->transformations as $transformation) {
$transformation->setParameters(array_merge($transformation->getParameters(), $this->getParameters()));
}
}
}
@@ -98,6 +98,7 @@ public function load($nameOrPath)
'phpDocumentor\Transformer\Template',
'xml'
);
$template->propagateParameters();
$this[$template->getName()] = $template;
}
@@ -0,0 +1,52 @@
<?php
/**
* phpDocumentor
*
* PHP Version 5.3
*
* @copyright 2010-2013 Mike van Riel / Naenius (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Transformer\Template;
use JMS\Serializer\Annotation as Serializer;
/**
* Model representing a parameter in a template or transformation.
*
* @Serializer\XmlRoot("parameter")
*/
class Parameter
{
/**
* @Serializer\Type("string")
* @var string
* @Serializer\XmlAttribute
*/
protected $key;
/**
* @Serializer\Type("string")
* @var string
* @Serializer\XmlValue
*/
protected $value;
/**
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* @return string
*/
public function getValue()
{
return $this->value;
}
}
@@ -53,7 +53,8 @@ class Transformation
protected $transformer;
/**
* @Serializer\Type("array")
* @Serializer\XmlMap(keyAttribute="key", entry="parameter")
* @Serializer\Type("array<string, string>")
* @var string[]
*/
protected $parameters = array();

0 comments on commit 8de4b96

Please sign in to comment.
You can’t perform that action at this time.