mirror of
https://github.com/flarum/framework.git
synced 2025-02-06 22:50:44 +08:00
Allow passing strings (names of invokable classes) to Formatter extender
In preparation for fixing #1703.
This commit is contained in:
parent
2c6398b8e3
commit
e27cd69974
|
@ -21,7 +21,7 @@ class Formatter implements ExtenderInterface, LifecycleInterface
|
||||||
{
|
{
|
||||||
protected $callback;
|
protected $callback;
|
||||||
|
|
||||||
public function configure(callable $callback)
|
public function configure($callback)
|
||||||
{
|
{
|
||||||
$this->callback = $callback;
|
$this->callback = $callback;
|
||||||
|
|
||||||
|
@ -34,8 +34,14 @@ class Formatter implements ExtenderInterface, LifecycleInterface
|
||||||
|
|
||||||
$events->listen(
|
$events->listen(
|
||||||
Configuring::class,
|
Configuring::class,
|
||||||
function (Configuring $event) {
|
function (Configuring $event) use ($container) {
|
||||||
call_user_func($this->callback, $event->configurator);
|
if (is_string($this->callback)) {
|
||||||
|
$callback = $container->make($this->callback);
|
||||||
|
} else {
|
||||||
|
$callback = $this->callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
$callback($event->configurator);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user