From f69579c4b03dfd848b14610247af5c232ade3fa8 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 2 Jan 2018 22:51:12 +0100 Subject: [PATCH] Add FormatterConfiguration extender for extensions working with TextFormatter --- .../src/Extend/FormatterConfiguration.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 framework/core/src/Extend/FormatterConfiguration.php diff --git a/framework/core/src/Extend/FormatterConfiguration.php b/framework/core/src/Extend/FormatterConfiguration.php new file mode 100644 index 000000000..1608a35fd --- /dev/null +++ b/framework/core/src/Extend/FormatterConfiguration.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flarum\Extend; + +use Flarum\Formatter\Event\Configuring; +use Illuminate\Contracts\Container\Container; +use Illuminate\Events\Dispatcher; + +class FormatterConfiguration implements Extender +{ + protected $callback; + + public function __construct(callable $callback) + { + $this->callback = $callback; + } + + public function apply(Container $container) + { + $container->make(Dispatcher::class)->listen( + Configuring::class, + function (Configuring $event) { + call_user_func($this->callback, $event->configurator); + } + ); + } +}