PERF: avoid reinstantiation of event subscribers

This commit is contained in:
Toby Zerner 2015-07-27 11:53:47 +09:30
parent 19ef6ed637
commit 798bcaa5f4
6 changed files with 20 additions and 20 deletions

View File

@ -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']);
}
/**

View File

@ -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']);
}
/**

View File

@ -26,7 +26,7 @@ class DiscussionRenamedNotifier
*/
public function subscribe(Dispatcher $events)
{
$events->listen(DiscussionWasRenamed::class, __CLASS__.'@whenDiscussionWasRenamed');
$events->listen(DiscussionWasRenamed::class, [$this, 'whenDiscussionWasRenamed']);
}
/**

View File

@ -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']);
}
/**

View File

@ -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']);
}
/**

View File

@ -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)