1
0
mirror of https://github.com/flarum/core.git synced 2025-07-29 20:50:28 +02:00
Files
php-flarum/src/Extend/FormatterConfiguration.php
Franz Liedke 0af97c427c Re-introduce Compat extender
Turns out Container::call() does not work with invokable classes.
Thus, we need to wrap callables in a custom extender class to
support injecting any resolvable type-hint automatically.

Refs #851.
2018-01-10 19:32:57 +01:00

37 lines
839 B
PHP

<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* 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 __invoke(Container $container)
{
$container->make(Dispatcher::class)->listen(
Configuring::class,
function (Configuring $event) {
call_user_func($this->callback, $event->configurator);
}
);
}
}