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