From e27cd699741e6e96badbfc8ef8294804f1ef7d1d Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Sat, 15 Dec 2018 12:05:17 +0100 Subject: [PATCH] Allow passing strings (names of invokable classes) to Formatter extender In preparation for fixing #1703. --- framework/core/src/Extend/Formatter.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/framework/core/src/Extend/Formatter.php b/framework/core/src/Extend/Formatter.php index 1ae2a6ed8..2707432d2 100644 --- a/framework/core/src/Extend/Formatter.php +++ b/framework/core/src/Extend/Formatter.php @@ -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); } ); }