mirror of
https://github.com/flarum/core.git
synced 2025-07-20 00:01:17 +02:00
Add FormatterConfiguration extender for extensions working with TextFormatter
This commit is contained in:
36
framework/core/src/Extend/FormatterConfiguration.php
Normal file
36
framework/core/src/Extend/FormatterConfiguration.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?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 apply(Container $container)
|
||||||
|
{
|
||||||
|
$container->make(Dispatcher::class)->listen(
|
||||||
|
Configuring::class,
|
||||||
|
function (Configuring $event) {
|
||||||
|
call_user_func($this->callback, $event->configurator);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user