mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 16:52:46 +08:00
PERF: avoid reinstantiation of event subscribers
This commit is contained in:
parent
19ef6ed637
commit
798bcaa5f4
|
@ -33,11 +33,11 @@ class UserActivitySyncer
|
|||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen('Flarum\Events\PostWasPosted', __CLASS__.'@whenPostWasPosted');
|
||||
$events->listen('Flarum\Events\PostWasHidden', __CLASS__.'@whenPostWasHidden');
|
||||
$events->listen('Flarum\Events\PostWasRestored', __CLASS__.'@whenPostWasRestored');
|
||||
$events->listen('Flarum\Events\PostWasDeleted', __CLASS__.'@whenPostWasDeleted');
|
||||
$events->listen('Flarum\Events\UserWasRegistered', __CLASS__.'@whenUserWasRegistered');
|
||||
$events->listen('Flarum\Events\PostWasPosted', [$this, 'whenPostWasPosted']);
|
||||
$events->listen('Flarum\Events\PostWasHidden', [$this, 'whenPostWasHidden']);
|
||||
$events->listen('Flarum\Events\PostWasRestored', [$this, 'whenPostWasRestored']);
|
||||
$events->listen('Flarum\Events\PostWasDeleted', [$this, 'whenPostWasDeleted']);
|
||||
$events->listen('Flarum\Events\UserWasRegistered', [$this, 'whenUserWasRegistered']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,10 +14,10 @@ class DiscussionMetadataUpdater
|
|||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(PostWasPosted::class, __CLASS__.'@whenPostWasPosted');
|
||||
$events->listen(PostWasDeleted::class, __CLASS__.'@whenPostWasDeleted');
|
||||
$events->listen(PostWasHidden::class, __CLASS__.'@whenPostWasHidden');
|
||||
$events->listen(PostWasRestored::class, __CLASS__.'@whenPostWasRestored');
|
||||
$events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']);
|
||||
$events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']);
|
||||
$events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']);
|
||||
$events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,7 @@ class DiscussionRenamedNotifier
|
|||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(DiscussionWasRenamed::class, __CLASS__.'@whenDiscussionWasRenamed');
|
||||
$events->listen(DiscussionWasRenamed::class, [$this, 'whenDiscussionWasRenamed']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,8 +37,8 @@ class EmailConfirmationMailer
|
|||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(UserWasRegistered::class, __CLASS__.'@whenUserWasRegistered');
|
||||
$events->listen(UserEmailChangeWasRequested::class, __CLASS__.'@whenUserEmailChangeWasRequested');
|
||||
$events->listen(UserWasRegistered::class, [$this, 'whenUserWasRegistered']);
|
||||
$events->listen(UserEmailChangeWasRequested::class, [$this, 'whenUserEmailChangeWasRequested']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,12 +16,12 @@ class UserMetadataUpdater
|
|||
*/
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(PostWasPosted::class, __CLASS__.'@whenPostWasPosted');
|
||||
$events->listen(PostWasDeleted::class, __CLASS__.'@whenPostWasDeleted');
|
||||
$events->listen(PostWasHidden::class, __CLASS__.'@whenPostWasHidden');
|
||||
$events->listen(PostWasRestored::class, __CLASS__.'@whenPostWasRestored');
|
||||
$events->listen(DiscussionWasStarted::class, __CLASS__.'@whenDiscussionWasStarted');
|
||||
$events->listen(DiscussionWasDeleted::class, __CLASS__.'@whenDiscussionWasDeleted');
|
||||
$events->listen(PostWasPosted::class, [$this, 'whenPostWasPosted']);
|
||||
$events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']);
|
||||
$events->listen(PostWasHidden::class, [$this, 'whenPostWasHidden']);
|
||||
$events->listen(PostWasRestored::class, [$this, 'whenPostWasRestored']);
|
||||
$events->listen(DiscussionWasStarted::class, [$this, 'whenDiscussionWasStarted']);
|
||||
$events->listen(DiscussionWasDeleted::class, [$this, 'whenDiscussionWasDeleted']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,8 +8,8 @@ class AddClientAssets
|
|||
{
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(RegisterLocales::class, __CLASS__.'@addLocale');
|
||||
$events->listen(BuildClientView::class, __CLASS__.'@addAssets');
|
||||
$events->listen(RegisterLocales::class, [$this, 'addLocale']);
|
||||
$events->listen(BuildClientView::class, [$this, 'addAssets']);
|
||||
}
|
||||
|
||||
public function addLocale(RegisterLocales $event)
|
||||
|
|
Loading…
Reference in New Issue
Block a user