mirror of
https://github.com/flarum/framework.git
synced 2025-02-22 06:13:10 +08:00
parent
9fe671c9bb
commit
dbe8cba14e
@ -15,7 +15,6 @@ use Flarum\Discussion\Event\Renamed;
|
||||
use Flarum\Notification\Blueprint\DiscussionRenamedBlueprint;
|
||||
use Flarum\Notification\NotificationSyncer;
|
||||
use Flarum\Post\DiscussionRenamedPost;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class DiscussionRenamedLogger
|
||||
{
|
||||
@ -29,12 +28,7 @@ class DiscussionRenamedLogger
|
||||
$this->notifications = $notifications;
|
||||
}
|
||||
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(Renamed::class, [$this, 'whenDiscussionWasRenamed']);
|
||||
}
|
||||
|
||||
public function whenDiscussionWasRenamed(Renamed $event)
|
||||
public function handle(Renamed $event)
|
||||
{
|
||||
$post = DiscussionRenamedPost::reply(
|
||||
$event->discussion->id,
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Flarum\Discussion;
|
||||
|
||||
use Flarum\Discussion\Event\Renamed;
|
||||
use Flarum\Foundation\AbstractServiceProvider;
|
||||
|
||||
class DiscussionServiceProvider extends AbstractServiceProvider
|
||||
@ -24,6 +25,9 @@ class DiscussionServiceProvider extends AbstractServiceProvider
|
||||
|
||||
$events->subscribe(DiscussionMetadataUpdater::class);
|
||||
$events->subscribe(DiscussionPolicy::class);
|
||||
$events->subscribe(DiscussionRenamedLogger::class);
|
||||
|
||||
$events->listen(
|
||||
Renamed::class, DiscussionRenamedLogger::class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ namespace Flarum\Extension;
|
||||
use Flarum\Extension\Event\Disabling;
|
||||
use Flarum\Http\Exception\ForbiddenException;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class DefaultLanguagePackGuard
|
||||
{
|
||||
@ -28,19 +27,7 @@ class DefaultLanguagePackGuard
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Dispatcher $events
|
||||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(Disabling::class, [$this, 'whenExtensionWillBeDisabled']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Disabling $event
|
||||
* @throws ForbiddenException
|
||||
*/
|
||||
public function whenExtensionWillBeDisabled(Disabling $event)
|
||||
public function handle(Disabling $event)
|
||||
{
|
||||
if (! in_array('flarum-locale', $event->extension->extra)) {
|
||||
return;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Flarum\Extension;
|
||||
|
||||
use Flarum\Extension\Event\Disabling;
|
||||
use Flarum\Foundation\AbstractServiceProvider;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
@ -38,8 +39,9 @@ class ExtensionServiceProvider extends AbstractServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$events = $this->app->make('events');
|
||||
|
||||
$events->subscribe(DefaultLanguagePackGuard::class);
|
||||
$this->app->make('events')->listen(
|
||||
Disabling::class,
|
||||
DefaultLanguagePackGuard::class
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user