Allow passing strings (names of invokable classes) to Formatter extender

In preparation for fixing #1703.
This commit is contained in:
Franz Liedke 2018-12-15 12:05:17 +01:00
parent f0da3cf304
commit 565131e2a7
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4

View File

@ -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);
}
);
}