From d8cb3c7605afaf47d4169ab017eb5f820bcada94 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 27 Jul 2015 11:54:52 +0930 Subject: [PATCH] PERF: avoid reinstantiation of event subscribers --- extensions/tags/src/Listeners/AddApiAttributes.php | 8 ++++---- extensions/tags/src/Listeners/AddClientAssets.php | 6 +++--- .../tags/src/Listeners/AddModelRelationship.php | 2 +- extensions/tags/src/Listeners/AddTagGambit.php | 2 +- .../Listeners/ConfigureDiscussionPermissions.php | 4 ++-- .../tags/src/Listeners/ConfigureTagPermissions.php | 4 ++-- .../tags/src/Listeners/LogDiscussionTagged.php | 4 ++-- extensions/tags/src/Listeners/PersistData.php | 2 +- .../tags/src/Listeners/UpdateTagMetadata.php | 14 +++++++------- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/extensions/tags/src/Listeners/AddApiAttributes.php b/extensions/tags/src/Listeners/AddApiAttributes.php index 198ac8a9d..9935eedf4 100755 --- a/extensions/tags/src/Listeners/AddApiAttributes.php +++ b/extensions/tags/src/Listeners/AddApiAttributes.php @@ -14,10 +14,10 @@ class AddApiAttributes { public function subscribe($events) { - $events->listen(ApiRelationship::class, __CLASS__.'@addTagsRelationship'); - $events->listen(WillSerializeData::class, __CLASS__.'@loadTagsRelationship'); - $events->listen(BuildApiAction::class, __CLASS__.'@includeTagsRelationship'); - $events->listen(ApiAttributes::class, __CLASS__.'@addAttributes'); + $events->listen(ApiRelationship::class, [$this, 'addTagsRelationship']); + $events->listen(WillSerializeData::class, [$this, 'loadTagsRelationship']); + $events->listen(BuildApiAction::class, [$this, 'includeTagsRelationship']); + $events->listen(ApiAttributes::class, [$this, 'addAttributes']); } public function addTagsRelationship(ApiRelationship $event) diff --git a/extensions/tags/src/Listeners/AddClientAssets.php b/extensions/tags/src/Listeners/AddClientAssets.php index 9eb24ee8b..904d97e50 100755 --- a/extensions/tags/src/Listeners/AddClientAssets.php +++ b/extensions/tags/src/Listeners/AddClientAssets.php @@ -9,9 +9,9 @@ class AddClientAssets { public function subscribe(Dispatcher $events) { - $events->listen(RegisterLocales::class, __CLASS__.'@addLocale'); - $events->listen(BuildClientView::class, __CLASS__.'@addAssets'); - $events->listen(RegisterForumRoutes::class, __CLASS__.'@addRoutes'); + $events->listen(RegisterLocales::class, [$this, 'addLocale']); + $events->listen(BuildClientView::class, [$this, 'addAssets']); + $events->listen(RegisterForumRoutes::class, [$this, 'addRoutes']); } public function addLocale(RegisterLocales $event) diff --git a/extensions/tags/src/Listeners/AddModelRelationship.php b/extensions/tags/src/Listeners/AddModelRelationship.php index f80741e7b..89af0180b 100755 --- a/extensions/tags/src/Listeners/AddModelRelationship.php +++ b/extensions/tags/src/Listeners/AddModelRelationship.php @@ -8,7 +8,7 @@ class AddModelRelationship { public function subscribe($events) { - $events->listen(ModelRelationship::class, __CLASS__.'@addTagsRelationship'); + $events->listen(ModelRelationship::class, [$this, 'addTagsRelationship']); } public function addTagsRelationship(ModelRelationship $event) diff --git a/extensions/tags/src/Listeners/AddTagGambit.php b/extensions/tags/src/Listeners/AddTagGambit.php index 9a06affef..80081af59 100755 --- a/extensions/tags/src/Listeners/AddTagGambit.php +++ b/extensions/tags/src/Listeners/AddTagGambit.php @@ -7,7 +7,7 @@ class AddTagGambit { public function subscribe(Dispatcher $events) { - $events->listen(RegisterDiscussionGambits::class, __CLASS__.'@registerTagGambit'); + $events->listen(RegisterDiscussionGambits::class, [$this, 'registerTagGambit']); } public function registerTagGambit(RegisterDiscussionGambits $event) diff --git a/extensions/tags/src/Listeners/ConfigureDiscussionPermissions.php b/extensions/tags/src/Listeners/ConfigureDiscussionPermissions.php index 00ac21d88..821aecb8e 100755 --- a/extensions/tags/src/Listeners/ConfigureDiscussionPermissions.php +++ b/extensions/tags/src/Listeners/ConfigureDiscussionPermissions.php @@ -9,8 +9,8 @@ class ConfigureDiscussionPermissions { public function subscribe($events) { - $events->listen(ScopeModelVisibility::class, __CLASS__.'@scopeDiscussionVisibility'); - $events->listen(ModelAllow::class, __CLASS__.'@allowDiscussionPermissions'); + $events->listen(ScopeModelVisibility::class, [$this, 'scopeDiscussionVisibility']); + $events->listen(ModelAllow::class, [$this, 'allowDiscussionPermissions']); } public function scopeDiscussionVisibility(ScopeModelVisibility $event) diff --git a/extensions/tags/src/Listeners/ConfigureTagPermissions.php b/extensions/tags/src/Listeners/ConfigureTagPermissions.php index 404857bb4..3db35e129 100755 --- a/extensions/tags/src/Listeners/ConfigureTagPermissions.php +++ b/extensions/tags/src/Listeners/ConfigureTagPermissions.php @@ -8,8 +8,8 @@ class ConfigureTagPermissions { public function subscribe($events) { - $events->listen(ScopeModelVisibility::class, __CLASS__.'@scopeTagVisibility'); - $events->listen(ModelAllow::class, __CLASS__.'@allowStartDiscussion'); + $events->listen(ScopeModelVisibility::class, [$this, 'scopeTagVisibility']); + $events->listen(ModelAllow::class, [$this, 'allowStartDiscussion']); } public function scopeTagVisibility(ScopeModelVisibility $event) diff --git a/extensions/tags/src/Listeners/LogDiscussionTagged.php b/extensions/tags/src/Listeners/LogDiscussionTagged.php index 1d8fa0f9e..e44951eee 100755 --- a/extensions/tags/src/Listeners/LogDiscussionTagged.php +++ b/extensions/tags/src/Listeners/LogDiscussionTagged.php @@ -9,8 +9,8 @@ class LogDiscussionTagged { public function subscribe(Dispatcher $events) { - $events->listen(RegisterPostTypes::class, __CLASS__.'@registerPostType'); - $events->listen(DiscussionWasTagged::class, __CLASS__.'@whenDiscussionWasTagged'); + $events->listen(RegisterPostTypes::class, [$this, 'registerPostType']); + $events->listen(DiscussionWasTagged::class, [$this, 'whenDiscussionWasTagged']); } public function registerPostType(RegisterPostTypes $event) diff --git a/extensions/tags/src/Listeners/PersistData.php b/extensions/tags/src/Listeners/PersistData.php index 320021dc8..6099b1f19 100755 --- a/extensions/tags/src/Listeners/PersistData.php +++ b/extensions/tags/src/Listeners/PersistData.php @@ -10,7 +10,7 @@ class PersistData { public function subscribe($events) { - $events->listen(DiscussionWillBeSaved::class, __CLASS__.'@whenDiscussionWillBeSaved'); + $events->listen(DiscussionWillBeSaved::class, [$this, 'whenDiscussionWillBeSaved']); } public function whenDiscussionWillBeSaved(DiscussionWillBeSaved $event) diff --git a/extensions/tags/src/Listeners/UpdateTagMetadata.php b/extensions/tags/src/Listeners/UpdateTagMetadata.php index ef00f3c41..a26343de6 100755 --- a/extensions/tags/src/Listeners/UpdateTagMetadata.php +++ b/extensions/tags/src/Listeners/UpdateTagMetadata.php @@ -15,14 +15,14 @@ class UpdateTagMetadata { public function subscribe($events) { - $events->listen(DiscussionWasStarted::class, __CLASS__.'@whenDiscussionWasStarted'); - $events->listen(DiscussionWasTagged::class, __CLASS__.'@whenDiscussionWasTagged'); - $events->listen(DiscussionWasDeleted::class, __CLASS__.'@whenDiscussionWasDeleted'); + $events->listen(DiscussionWasStarted::class, [$this, 'whenDiscussionWasStarted']); + $events->listen(DiscussionWasTagged::class, [$this, 'whenDiscussionWasTagged']); + $events->listen(DiscussionWasDeleted::class, [$this, 'whenDiscussionWasDeleted']); - $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']); } public function whenDiscussionWasStarted(DiscussionWasStarted $event)