1
0
mirror of https://github.com/flarum/core.git synced 2025-08-07 00:47:00 +02:00

PERF: avoid reinstantiation of event subscribers

This commit is contained in:
Toby Zerner
2015-07-27 11:54:13 +09:30
parent d7ac8aac2e
commit 05cfb6af62
5 changed files with 11 additions and 11 deletions

View File

@@ -12,9 +12,9 @@ class AddApiAttributes
{
public function subscribe(Dispatcher $events)
{
$events->listen(ApiAttributes::class, __CLASS__.'@addAttributes');
$events->listen(ApiRelationship::class, __CLASS__.'@addRelationship');
$events->listen(BuildApiAction::class, __CLASS__.'@includeLikes');
$events->listen(ApiAttributes::class, [$this, 'addAttributes']);
$events->listen(ApiRelationship::class, [$this, 'addRelationship']);
$events->listen(BuildApiAction::class, [$this, 'includeLikes']);
}
public function addAttributes(ApiAttributes $event)

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)

View File

@@ -8,7 +8,7 @@ class AddModelRelationship
{
public function subscribe(Dispatcher $events)
{
$events->listen(ModelRelationship::class, __CLASS__.'@addRelationship');
$events->listen(ModelRelationship::class, [$this, 'addRelationship']);
}
public function addRelationship(ModelRelationship $event)

View File

@@ -20,9 +20,9 @@ class NotifyPostLiked
public function subscribe(Dispatcher $events)
{
$events->listen(RegisterNotificationTypes::class, __CLASS__.'@registerNotificationType');
$events->listen(PostWasLiked::class, __CLASS__.'@whenPostWasLiked');
$events->listen(PostWasUnliked::class, __CLASS__.'@whenPostWasUnliked');
$events->listen(RegisterNotificationTypes::class, [$this, 'registerNotificationType']);
$events->listen(PostWasLiked::class, [$this, 'whenPostWasLiked']);
$events->listen(PostWasUnliked::class, [$this, 'whenPostWasUnliked']);
}
public function registerNotificationType(RegisterNotificationTypes $event)

View File

@@ -12,8 +12,8 @@ class PersistData
{
public function subscribe(Dispatcher $events)
{
$events->listen(PostWillBeSaved::class, __CLASS__.'@whenPostWillBeSaved');
$events->listen(PostWasDeleted::class, __CLASS__.'@whenPostWasDeleted');
$events->listen(PostWillBeSaved::class, [$this, 'whenPostWillBeSaved']);
$events->listen(PostWasDeleted::class, [$this, 'whenPostWasDeleted']);
}
public function whenPostWillBeSaved(PostWillBeSaved $event)