mirror of
https://github.com/flarum/framework.git
synced 2025-03-03 23:07:56 +08:00
Allow extensions to modify text/XML prior to formatting
This commit is contained in:
parent
f50a11b885
commit
80d75fe712
@ -24,13 +24,20 @@ class ConfigureFormatterParser
|
|||||||
*/
|
*/
|
||||||
public $context;
|
public $context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Parser $parser
|
* @param Parser $parser
|
||||||
* @param mixed $context
|
* @param mixed $context
|
||||||
|
* @param string $text
|
||||||
*/
|
*/
|
||||||
public function __construct(Parser $parser, $context)
|
public function __construct(Parser $parser, $context, &$text)
|
||||||
{
|
{
|
||||||
$this->parser = $parser;
|
$this->parser = $parser;
|
||||||
$this->context = $context;
|
$this->context = $context;
|
||||||
|
$this->text = &$text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,20 @@ class ConfigureFormatterRenderer
|
|||||||
*/
|
*/
|
||||||
public $context;
|
public $context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $xml;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Renderer $renderer
|
* @param Renderer $renderer
|
||||||
* @param mixed $context
|
* @param mixed $context
|
||||||
|
* @param string $xml
|
||||||
*/
|
*/
|
||||||
public function __construct(Renderer $renderer, $context)
|
public function __construct(Renderer $renderer, $context, &$xml)
|
||||||
{
|
{
|
||||||
$this->renderer = $renderer;
|
$this->renderer = $renderer;
|
||||||
$this->context = $context;
|
$this->context = $context;
|
||||||
|
$this->xml = &$xml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,8 @@ class Formatter
|
|||||||
{
|
{
|
||||||
$parser = $this->getParser($context);
|
$parser = $this->getParser($context);
|
||||||
|
|
||||||
|
$this->events->fire(new ConfigureFormatterParser($parser, $context, $text));
|
||||||
|
|
||||||
return $parser->parse($text);
|
return $parser->parse($text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +74,8 @@ class Formatter
|
|||||||
{
|
{
|
||||||
$renderer = $this->getRenderer($context);
|
$renderer = $this->getRenderer($context);
|
||||||
|
|
||||||
|
$this->events->fire(new ConfigureFormatterRenderer($renderer, $context, $xml));
|
||||||
|
|
||||||
return $renderer->render($xml);
|
return $renderer->render($xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,8 +165,6 @@ class Formatter
|
|||||||
|
|
||||||
$parser->registeredVars['context'] = $context;
|
$parser->registeredVars['context'] = $context;
|
||||||
|
|
||||||
$this->events->fire(new ConfigureFormatterParser($parser, $context));
|
|
||||||
|
|
||||||
return $parser;
|
return $parser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,11 +182,7 @@ class Formatter
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$renderer = $this->getComponent('renderer');
|
return $this->getComponent('renderer');
|
||||||
|
|
||||||
$this->events->fire(new ConfigureFormatterRenderer($renderer, $context));
|
|
||||||
|
|
||||||
return $renderer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user