Allow extensions to modify text/XML prior to formatting

This commit is contained in:
Toby Zerner 2015-12-30 15:27:34 +10:30
parent bf87518161
commit 5a4e3b09cf
3 changed files with 21 additions and 9 deletions

View File

@ -24,13 +24,20 @@ class ConfigureFormatterParser
*/
public $context;
/**
* @var string
*/
public $text;
/**
* @param Parser $parser
* @param mixed $context
* @param string $text
*/
public function __construct(Parser $parser, $context)
public function __construct(Parser $parser, $context, &$text)
{
$this->parser = $parser;
$this->context = $context;
$this->text = &$text;
}
}

View File

@ -24,13 +24,20 @@ class ConfigureFormatterRenderer
*/
public $context;
/**
* @var string
*/
public $xml;
/**
* @param Renderer $renderer
* @param mixed $context
* @param string $xml
*/
public function __construct(Renderer $renderer, $context)
public function __construct(Renderer $renderer, $context, &$xml)
{
$this->renderer = $renderer;
$this->context = $context;
$this->xml = &$xml;
}
}

View File

@ -58,6 +58,8 @@ class Formatter
{
$parser = $this->getParser($context);
$this->events->fire(new ConfigureFormatterParser($parser, $context, $text));
return $parser->parse($text);
}
@ -72,6 +74,8 @@ class Formatter
{
$renderer = $this->getRenderer($context);
$this->events->fire(new ConfigureFormatterRenderer($renderer, $context, $xml));
return $renderer->render($xml);
}
@ -161,8 +165,6 @@ class Formatter
$parser->registeredVars['context'] = $context;
$this->events->fire(new ConfigureFormatterParser($parser, $context));
return $parser;
}
@ -180,11 +182,7 @@ class Formatter
}
});
$renderer = $this->getComponent('renderer');
$this->events->fire(new ConfigureFormatterRenderer($renderer, $context));
return $renderer;
return $this->getComponent('renderer');
}
/**