mirror of
https://github.com/flarum/framework.git
synced 2025-02-28 15:26:26 +08:00
fixed the Bus command Handling forwarding the call to a matching Handler class
This commit is contained in:
parent
0bd569aa75
commit
ccfa3482f1
28
framework/core/src/Bus/BusServiceProvider.php
Normal file
28
framework/core/src/Bus/BusServiceProvider.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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\Bus;
|
||||||
|
|
||||||
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
|
use Illuminate\Contracts\Bus\Dispatcher as BusContract;
|
||||||
|
use Illuminate\Contracts\Queue\Factory as QueueFactoryContract;
|
||||||
|
|
||||||
|
class BusServiceProvider extends AbstractServiceProvider
|
||||||
|
{
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->app->bind(BusContract::class, function ($app) {
|
||||||
|
return new Dispatcher($app, function ($connection = null) use ($app) {
|
||||||
|
return $app[QueueFactoryContract::class]->connection($connection);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
19
framework/core/src/Bus/Dispatcher.php
Normal file
19
framework/core/src/Bus/Dispatcher.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flarum\Bus;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Dispatcher as BaseDispatcher;
|
||||||
|
|
||||||
|
class Dispatcher extends BaseDispatcher
|
||||||
|
{
|
||||||
|
public function getCommandHandler($command)
|
||||||
|
{
|
||||||
|
$handler = get_class($command) . 'Handler';
|
||||||
|
|
||||||
|
if (class_exists($handler)) {
|
||||||
|
return $this->container->make($handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::getCommandHandler($command);
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ namespace Flarum\Foundation;
|
|||||||
|
|
||||||
use Flarum\Admin\AdminServiceProvider;
|
use Flarum\Admin\AdminServiceProvider;
|
||||||
use Flarum\Api\ApiServiceProvider;
|
use Flarum\Api\ApiServiceProvider;
|
||||||
|
use Flarum\Bus\BusServiceProvider as BusProvider;
|
||||||
use Flarum\Database\DatabaseServiceProvider;
|
use Flarum\Database\DatabaseServiceProvider;
|
||||||
use Flarum\Database\MigrationServiceProvider;
|
use Flarum\Database\MigrationServiceProvider;
|
||||||
use Flarum\Discussion\DiscussionServiceProvider;
|
use Flarum\Discussion\DiscussionServiceProvider;
|
||||||
@ -166,6 +167,8 @@ class Site
|
|||||||
$app->register(ViewServiceProvider::class);
|
$app->register(ViewServiceProvider::class);
|
||||||
$app->register(ValidationServiceProvider::class);
|
$app->register(ValidationServiceProvider::class);
|
||||||
|
|
||||||
|
$app->register(BusProvider::class);
|
||||||
|
|
||||||
if ($app->isInstalled() && $app->isUpToDate()) {
|
if ($app->isInstalled() && $app->isUpToDate()) {
|
||||||
$settings = $app->make(SettingsRepositoryInterface::class);
|
$settings = $app->make(SettingsRepositoryInterface::class);
|
||||||
|
|
||||||
|
@ -14,9 +14,11 @@ namespace Flarum\Locale;
|
|||||||
use Flarum\Event\ConfigureLocales;
|
use Flarum\Event\ConfigureLocales;
|
||||||
use Flarum\Foundation\AbstractServiceProvider;
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
use Symfony\Component\Translation\MessageSelector;
|
use Illuminate\Translation\Translator;
|
||||||
use Symfony\Component\Translation\Translator;
|
use Illuminate\Translation\FileLoader;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
//use Symfony\Component\Translation\MessageSelector;
|
||||||
|
//use Symfony\Component\Translation\Translator;
|
||||||
|
//use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
|
||||||
class LocaleServiceProvider extends AbstractServiceProvider
|
class LocaleServiceProvider extends AbstractServiceProvider
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user