mirror of
https://github.com/flarum/framework.git
synced 2024-11-27 19:13:37 +08:00
Allow passing strings (names of invokable classes) to Formatter extender
In preparation for fixing #1703.
This commit is contained in:
parent
f0da3cf304
commit
565131e2a7
|
@ -21,7 +21,7 @@ class Formatter implements ExtenderInterface, LifecycleInterface
|
|||
{
|
||||
protected $callback;
|
||||
|
||||
public function configure(callable $callback)
|
||||
public function configure($callback)
|
||||
{
|
||||
$this->callback = $callback;
|
||||
|
||||
|
@ -34,8 +34,14 @@ class Formatter implements ExtenderInterface, LifecycleInterface
|
|||
|
||||
$events->listen(
|
||||
Configuring::class,
|
||||
function (Configuring $event) {
|
||||
call_user_func($this->callback, $event->configurator);
|
||||
function (Configuring $event) use ($container) {
|
||||
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