From d66972c9f29569ed11c313fffd11d193c9ff063f Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 21 Oct 2013 17:00:21 -0700 Subject: [PATCH] Tie application event listeners to the applications they listen for Summary: Ref T3675. Some of these listeners shouldn't do their thing if the viewer doesn't have access to an application (for example, users without access to Differential should not be able to "Edit Tasks"). Set the stage for that: - Introduce `PhabricatorEventListener`, which has an application. - Populate this for event listeners installed by applications. - Rename the "PeopleMenu" listeners to "ActionMenu" listeners, which better describes their modern behavior. This doesn't actually change any behaviors. Test Plan: Viewed Maniphest, Differntial, People. Reviewers: btrahan, chad Reviewed By: btrahan CC: aran Maniphest Tasks: T3675 Differential Revision: https://secure.phabricator.com/D7364 --- src/__phutil_library_map__.php | 48 ++++++++++--------- .../event/DarkConsoleEventPluginAPI.php | 2 +- .../PhabricatorApplicationAudit.php | 2 +- ...r.php => AuditActionMenuEventListener.php} | 2 +- .../PhabricatorApplicationConpherence.php | 2 +- ...=> ConpherenceActionMenuEventListener.php} | 3 +- .../ConpherenceHovercardEventListener.php | 2 +- .../event/PhabricatorDaemonEventListener.php | 2 +- .../PhabricatorApplicationDifferential.php | 2 +- ...> DifferentialActionMenuEventListener.php} | 3 +- .../DifferentialHovercardEventListener.php | 3 +- .../DiffusionHovercardEventListener.php | 2 +- .../PhabricatorFlagsUIEventListener.php | 2 +- .../PhabricatorApplicationManiphest.php | 2 +- ...p => ManiphestActionMenuEventListener.php} | 2 +- .../event/ManiphestEdgeEventListener.php | 2 +- .../event/ManiphestHovercardEventListener.php | 2 +- .../event/ManiphestNameIndexEventListener.php | 2 +- ...habricatorPeopleHovercardEventListener.php | 2 +- .../event/PhrequentUIEventListener.php | 2 +- .../PhrictionActionMenuEventListener.php | 2 +- ...habricatorSubscriptionsUIEventListener.php | 2 +- .../event/PhabricatorTokenUIEventListener.php | 2 +- .../events/PhabricatorEventEngine.php | 1 + .../events/PhabricatorEventListener.php | 36 ++++++++++++++ .../PhabricatorExampleEventListener.php | 2 +- 26 files changed, 88 insertions(+), 46 deletions(-) rename src/applications/audit/events/{AuditPeopleMenuEventListener.php => AuditActionMenuEventListener.php} (92%) rename src/applications/conpherence/events/{ConpherencePeopleMenuEventListener.php => ConpherenceActionMenuEventListener.php} (90%) rename src/applications/differential/events/{DifferentialPeopleMenuEventListener.php => DifferentialActionMenuEventListener.php} (91%) rename src/applications/maniphest/event/{ManiphestPeopleMenuEventListener.php => ManiphestActionMenuEventListener.php} (93%) create mode 100644 src/infrastructure/events/PhabricatorEventListener.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 50af7d8448..2bc74bbcde 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -90,7 +90,7 @@ phutil_register_library_map(array( 'AphrontUsageException' => 'aphront/exception/AphrontUsageException.php', 'AphrontView' => 'view/AphrontView.php', 'AphrontWebpageResponse' => 'aphront/response/AphrontWebpageResponse.php', - 'AuditPeopleMenuEventListener' => 'applications/audit/events/AuditPeopleMenuEventListener.php', + 'AuditActionMenuEventListener' => 'applications/audit/events/AuditActionMenuEventListener.php', 'CelerityAPI' => 'infrastructure/celerity/CelerityAPI.php', 'CelerityPhabricatorResourceController' => 'infrastructure/celerity/CelerityPhabricatorResourceController.php', 'CelerityResourceController' => 'infrastructure/celerity/CelerityResourceController.php', @@ -244,6 +244,7 @@ phutil_register_library_map(array( 'ConduitCallTestCase' => 'applications/conduit/call/__tests__/ConduitCallTestCase.php', 'ConduitException' => 'applications/conduit/protocol/ConduitException.php', 'ConduitSSHWorkflow' => 'applications/conduit/ssh/ConduitSSHWorkflow.php', + 'ConpherenceActionMenuEventListener' => 'applications/conpherence/events/ConpherenceActionMenuEventListener.php', 'ConpherenceConfigOptions' => 'applications/conpherence/config/ConpherenceConfigOptions.php', 'ConpherenceConstants' => 'applications/conpherence/constants/ConpherenceConstants.php', 'ConpherenceController' => 'applications/conpherence/controller/ConpherenceController.php', @@ -261,7 +262,6 @@ phutil_register_library_map(array( 'ConpherenceParticipantCountQuery' => 'applications/conpherence/query/ConpherenceParticipantCountQuery.php', 'ConpherenceParticipantQuery' => 'applications/conpherence/query/ConpherenceParticipantQuery.php', 'ConpherenceParticipationStatus' => 'applications/conpherence/constants/ConpherenceParticipationStatus.php', - 'ConpherencePeopleMenuEventListener' => 'applications/conpherence/events/ConpherencePeopleMenuEventListener.php', 'ConpherencePeopleWidgetView' => 'applications/conpherence/view/ConpherencePeopleWidgetView.php', 'ConpherenceReplyHandler' => 'applications/conpherence/mail/ConpherenceReplyHandler.php', 'ConpherenceSettings' => 'applications/conpherence/constants/ConpherenceSettings.php', @@ -297,6 +297,7 @@ phutil_register_library_map(array( 'DefaultDatabaseConfigurationProvider' => 'infrastructure/storage/configuration/DefaultDatabaseConfigurationProvider.php', 'DifferentialAction' => 'applications/differential/constants/DifferentialAction.php', 'DifferentialActionHasNoEffectException' => 'applications/differential/exception/DifferentialActionHasNoEffectException.php', + 'DifferentialActionMenuEventListener' => 'applications/differential/events/DifferentialActionMenuEventListener.php', 'DifferentialAddCommentView' => 'applications/differential/view/DifferentialAddCommentView.php', 'DifferentialAffectedPath' => 'applications/differential/storage/DifferentialAffectedPath.php', 'DifferentialApplyPatchFieldSpecification' => 'applications/differential/field/specification/DifferentialApplyPatchFieldSpecification.php', @@ -390,7 +391,6 @@ phutil_register_library_map(array( 'DifferentialPHIDTypeRevision' => 'applications/differential/phid/DifferentialPHIDTypeRevision.php', 'DifferentialParseRenderTestCase' => 'applications/differential/__tests__/DifferentialParseRenderTestCase.php', 'DifferentialPathFieldSpecification' => 'applications/differential/field/specification/DifferentialPathFieldSpecification.php', - 'DifferentialPeopleMenuEventListener' => 'applications/differential/events/DifferentialPeopleMenuEventListener.php', 'DifferentialPrimaryPaneView' => 'applications/differential/view/DifferentialPrimaryPaneView.php', 'DifferentialProjectReviewersFieldSpecification' => 'applications/differential/field/specification/DifferentialProjectReviewersFieldSpecification.php', 'DifferentialRawDiffRenderer' => 'applications/differential/render/DifferentialRawDiffRenderer.php', @@ -704,6 +704,7 @@ phutil_register_library_map(array( 'LiskIsolationTestDAOException' => 'infrastructure/storage/lisk/__tests__/LiskIsolationTestDAOException.php', 'LiskMigrationIterator' => 'infrastructure/storage/lisk/LiskMigrationIterator.php', 'LiskRawMigrationIterator' => 'infrastructure/storage/lisk/LiskRawMigrationIterator.php', + 'ManiphestActionMenuEventListener' => 'applications/maniphest/event/ManiphestActionMenuEventListener.php', 'ManiphestBatchEditController' => 'applications/maniphest/controller/ManiphestBatchEditController.php', 'ManiphestCapabilityBulkEdit' => 'applications/maniphest/capability/ManiphestCapabilityBulkEdit.php', 'ManiphestCapabilityDefaultEdit' => 'applications/maniphest/capability/ManiphestCapabilityDefaultEdit.php', @@ -730,7 +731,6 @@ phutil_register_library_map(array( 'ManiphestNameIndex' => 'applications/maniphest/storage/ManiphestNameIndex.php', 'ManiphestNameIndexEventListener' => 'applications/maniphest/event/ManiphestNameIndexEventListener.php', 'ManiphestPHIDTypeTask' => 'applications/maniphest/phid/ManiphestPHIDTypeTask.php', - 'ManiphestPeopleMenuEventListener' => 'applications/maniphest/event/ManiphestPeopleMenuEventListener.php', 'ManiphestRemarkupRule' => 'applications/maniphest/remarkup/ManiphestRemarkupRule.php', 'ManiphestReplyHandler' => 'applications/maniphest/mail/ManiphestReplyHandler.php', 'ManiphestReportController' => 'applications/maniphest/controller/ManiphestReportController.php', @@ -1157,6 +1157,7 @@ phutil_register_library_map(array( 'PhabricatorErrorExample' => 'applications/uiexample/examples/PhabricatorErrorExample.php', 'PhabricatorEvent' => 'infrastructure/events/PhabricatorEvent.php', 'PhabricatorEventEngine' => 'infrastructure/events/PhabricatorEventEngine.php', + 'PhabricatorEventListener' => 'infrastructure/events/PhabricatorEventListener.php', 'PhabricatorEventType' => 'infrastructure/events/constant/PhabricatorEventType.php', 'PhabricatorExampleEventListener' => 'infrastructure/events/PhabricatorExampleEventListener.php', 'PhabricatorExtendingPhabricatorConfigOptions' => 'applications/config/option/PhabricatorExtendingPhabricatorConfigOptions.php', @@ -2225,7 +2226,7 @@ phutil_register_library_map(array( 1 => 'PhutilSafeHTMLProducerInterface', ), 'AphrontWebpageResponse' => 'AphrontHTMLResponse', - 'AuditPeopleMenuEventListener' => 'PhutilEventListener', + 'AuditActionMenuEventListener' => 'PhabricatorEventListener', 'CelerityPhabricatorResourceController' => 'CelerityResourceController', 'CelerityResourceController' => 'PhabricatorController', 'CelerityResourceGraph' => 'AbstractDirectedGraph', @@ -2375,13 +2376,14 @@ phutil_register_library_map(array( 'ConduitCallTestCase' => 'PhabricatorTestCase', 'ConduitException' => 'Exception', 'ConduitSSHWorkflow' => 'PhabricatorSSHWorkflow', + 'ConpherenceActionMenuEventListener' => 'PhabricatorEventListener', 'ConpherenceConfigOptions' => 'PhabricatorApplicationConfigOptions', 'ConpherenceController' => 'PhabricatorController', 'ConpherenceCreateThreadMailReceiver' => 'PhabricatorMailReceiver', 'ConpherenceDAO' => 'PhabricatorLiskDAO', 'ConpherenceEditor' => 'PhabricatorApplicationTransactionEditor', 'ConpherenceFileWidgetView' => 'ConpherenceWidgetView', - 'ConpherenceHovercardEventListener' => 'PhutilEventListener', + 'ConpherenceHovercardEventListener' => 'PhabricatorEventListener', 'ConpherenceLayoutView' => 'AphrontView', 'ConpherenceListController' => 'ConpherenceController', 'ConpherenceMenuItemView' => 'AphrontTagView', @@ -2391,7 +2393,6 @@ phutil_register_library_map(array( 'ConpherenceParticipantCountQuery' => 'PhabricatorOffsetPagedQuery', 'ConpherenceParticipantQuery' => 'PhabricatorOffsetPagedQuery', 'ConpherenceParticipationStatus' => 'ConpherenceConstants', - 'ConpherencePeopleMenuEventListener' => 'PhutilEventListener', 'ConpherencePeopleWidgetView' => 'ConpherenceWidgetView', 'ConpherenceReplyHandler' => 'PhabricatorMailReplyHandler', 'ConpherenceSettings' => 'ConpherenceConstants', @@ -2418,12 +2419,13 @@ phutil_register_library_map(array( 'DarkConsoleDataController' => 'PhabricatorController', 'DarkConsoleErrorLogPlugin' => 'DarkConsolePlugin', 'DarkConsoleEventPlugin' => 'DarkConsolePlugin', - 'DarkConsoleEventPluginAPI' => 'PhutilEventListener', + 'DarkConsoleEventPluginAPI' => 'PhabricatorEventListener', 'DarkConsoleRequestPlugin' => 'DarkConsolePlugin', 'DarkConsoleServicesPlugin' => 'DarkConsolePlugin', 'DarkConsoleXHProfPlugin' => 'DarkConsolePlugin', 'DefaultDatabaseConfigurationProvider' => 'DatabaseConfigurationProvider', 'DifferentialActionHasNoEffectException' => 'DifferentialException', + 'DifferentialActionMenuEventListener' => 'PhabricatorEventListener', 'DifferentialAddCommentView' => 'AphrontView', 'DifferentialAffectedPath' => 'DifferentialDAO', 'DifferentialApplyPatchFieldSpecification' => 'DifferentialFieldSpecification', @@ -2496,7 +2498,7 @@ phutil_register_library_map(array( 'DifferentialFreeformFieldTestCase' => 'PhabricatorTestCase', 'DifferentialGitSVNIDFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialHostFieldSpecification' => 'DifferentialFieldSpecification', - 'DifferentialHovercardEventListener' => 'PhutilEventListener', + 'DifferentialHovercardEventListener' => 'PhabricatorEventListener', 'DifferentialHunk' => 'DifferentialDAO', 'DifferentialHunkParserTestCase' => 'PhabricatorTestCase', 'DifferentialHunkTestCase' => 'ArcanistPhutilTestCase', @@ -2516,7 +2518,6 @@ phutil_register_library_map(array( 'DifferentialPHIDTypeRevision' => 'PhabricatorPHIDType', 'DifferentialParseRenderTestCase' => 'PhabricatorTestCase', 'DifferentialPathFieldSpecification' => 'DifferentialFieldSpecification', - 'DifferentialPeopleMenuEventListener' => 'PhutilEventListener', 'DifferentialPrimaryPaneView' => 'AphrontView', 'DifferentialProjectReviewersFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialReleephRequestFieldSpecification' => 'DifferentialFieldSpecification', @@ -2601,7 +2602,7 @@ phutil_register_library_map(array( 'DiffusionGitStableCommitNameQuery' => 'DiffusionStableCommitNameQuery', 'DiffusionHistoryController' => 'DiffusionController', 'DiffusionHistoryTableView' => 'DiffusionView', - 'DiffusionHovercardEventListener' => 'PhutilEventListener', + 'DiffusionHovercardEventListener' => 'PhabricatorEventListener', 'DiffusionInlineCommentController' => 'PhabricatorInlineCommentController', 'DiffusionInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController', 'DiffusionLastModifiedController' => 'DiffusionController', @@ -2842,6 +2843,7 @@ phutil_register_library_map(array( 'LiskIsolationTestDAOException' => 'Exception', 'LiskMigrationIterator' => 'PhutilBufferedIterator', 'LiskRawMigrationIterator' => 'PhutilBufferedIterator', + 'ManiphestActionMenuEventListener' => 'PhabricatorEventListener', 'ManiphestBatchEditController' => 'ManiphestController', 'ManiphestCapabilityBulkEdit' => 'PhabricatorPolicyCapability', 'ManiphestCapabilityDefaultEdit' => 'PhabricatorPolicyCapability', @@ -2863,14 +2865,13 @@ phutil_register_library_map(array( 'ManiphestCustomFieldStorage' => 'PhabricatorCustomFieldStorage', 'ManiphestCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage', 'ManiphestDAO' => 'PhabricatorLiskDAO', - 'ManiphestEdgeEventListener' => 'PhutilEventListener', + 'ManiphestEdgeEventListener' => 'PhabricatorEventListener', 'ManiphestExcelDefaultFormat' => 'ManiphestExcelFormat', 'ManiphestExportController' => 'ManiphestController', - 'ManiphestHovercardEventListener' => 'PhutilEventListener', + 'ManiphestHovercardEventListener' => 'PhabricatorEventListener', 'ManiphestNameIndex' => 'ManiphestDAO', - 'ManiphestNameIndexEventListener' => 'PhutilEventListener', + 'ManiphestNameIndexEventListener' => 'PhabricatorEventListener', 'ManiphestPHIDTypeTask' => 'PhabricatorPHIDType', - 'ManiphestPeopleMenuEventListener' => 'PhutilEventListener', 'ManiphestRemarkupRule' => 'PhabricatorRemarkupRuleObject', 'ManiphestReplyHandler' => 'PhabricatorMailReplyHandler', 'ManiphestReportController' => 'ManiphestController', @@ -3289,7 +3290,7 @@ phutil_register_library_map(array( 'PhabricatorDaemonConsoleController' => 'PhabricatorDaemonController', 'PhabricatorDaemonController' => 'PhabricatorController', 'PhabricatorDaemonDAO' => 'PhabricatorLiskDAO', - 'PhabricatorDaemonEventListener' => 'PhutilEventListener', + 'PhabricatorDaemonEventListener' => 'PhabricatorEventListener', 'PhabricatorDaemonLog' => array( 0 => 'PhabricatorDaemonDAO', @@ -3340,8 +3341,9 @@ phutil_register_library_map(array( 'PhabricatorEnvTestCase' => 'PhabricatorTestCase', 'PhabricatorErrorExample' => 'PhabricatorUIExample', 'PhabricatorEvent' => 'PhutilEvent', + 'PhabricatorEventListener' => 'PhutilEventListener', 'PhabricatorEventType' => 'PhutilEventType', - 'PhabricatorExampleEventListener' => 'PhutilEventListener', + 'PhabricatorExampleEventListener' => 'PhabricatorEventListener', 'PhabricatorExtendingPhabricatorConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorExternalAccount' => array( @@ -3464,7 +3466,7 @@ phutil_register_library_map(array( 'PhabricatorFlagQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorFlagSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PhabricatorFlagSelectControl' => 'AphrontFormControl', - 'PhabricatorFlagsUIEventListener' => 'PhutilEventListener', + 'PhabricatorFlagsUIEventListener' => 'PhabricatorEventListener', 'PhabricatorFormExample' => 'PhabricatorUIExample', 'PhabricatorGarbageCollectorConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorGarbageCollectorDaemon' => 'PhabricatorDaemon', @@ -3670,7 +3672,7 @@ phutil_register_library_map(array( 'PhabricatorPasteViewController' => 'PhabricatorPasteController', 'PhabricatorPeopleController' => 'PhabricatorController', 'PhabricatorPeopleEditController' => 'PhabricatorPeopleController', - 'PhabricatorPeopleHovercardEventListener' => 'PhutilEventListener', + 'PhabricatorPeopleHovercardEventListener' => 'PhabricatorEventListener', 'PhabricatorPeopleLdapController' => 'PhabricatorPeopleController', 'PhabricatorPeopleListController' => array( @@ -3947,7 +3949,7 @@ phutil_register_library_map(array( 'PhabricatorSubscribersQuery' => 'PhabricatorQuery', 'PhabricatorSubscriptionsEditController' => 'PhabricatorController', 'PhabricatorSubscriptionsEditor' => 'PhabricatorEditor', - 'PhabricatorSubscriptionsUIEventListener' => 'PhutilEventListener', + 'PhabricatorSubscriptionsUIEventListener' => 'PhabricatorEventListener', 'PhabricatorSymbolNameLinter' => 'ArcanistXHPASTLintNamingHook', 'PhabricatorSyntaxHighlightingConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorTagExample' => 'PhabricatorUIExample', @@ -3984,7 +3986,7 @@ phutil_register_library_map(array( 'PhabricatorTokenPHIDTypeToken' => 'PhabricatorPHIDType', 'PhabricatorTokenQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorTokenReceiverQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', - 'PhabricatorTokenUIEventListener' => 'PhutilEventListener', + 'PhabricatorTokenUIEventListener' => 'PhabricatorEventListener', 'PhabricatorTransactionView' => 'AphrontView', 'PhabricatorTransformedFile' => 'PhabricatorFileDAO', 'PhabricatorTranslationsConfigOptions' => 'PhabricatorApplicationConfigOptions', @@ -4237,7 +4239,7 @@ phutil_register_library_map(array( 'PhrequentTimeBlock' => 'Phobject', 'PhrequentTimeBlockTestCase' => 'PhabricatorTestCase', 'PhrequentTrackController' => 'PhrequentController', - 'PhrequentUIEventListener' => 'PhutilEventListener', + 'PhrequentUIEventListener' => 'PhabricatorEventListener', 'PhrequentUserTime' => array( 0 => 'PhrequentDAO', @@ -4245,7 +4247,7 @@ phutil_register_library_map(array( ), 'PhrequentUserTimeQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhrictionActionConstants' => 'PhrictionConstants', - 'PhrictionActionMenuEventListener' => 'PhutilEventListener', + 'PhrictionActionMenuEventListener' => 'PhabricatorEventListener', 'PhrictionChangeType' => 'PhrictionConstants', 'PhrictionContent' => array( diff --git a/src/aphront/console/plugin/event/DarkConsoleEventPluginAPI.php b/src/aphront/console/plugin/event/DarkConsoleEventPluginAPI.php index 81cb040154..3298fb46c0 100644 --- a/src/aphront/console/plugin/event/DarkConsoleEventPluginAPI.php +++ b/src/aphront/console/plugin/event/DarkConsoleEventPluginAPI.php @@ -3,7 +3,7 @@ /** * @group console */ -final class DarkConsoleEventPluginAPI extends PhutilEventListener { +final class DarkConsoleEventPluginAPI extends PhabricatorEventListener { private static $events = array(); private static $discardMode = false; diff --git a/src/applications/audit/application/PhabricatorApplicationAudit.php b/src/applications/audit/application/PhabricatorApplicationAudit.php index f21f5ab558..ce0a120b16 100644 --- a/src/applications/audit/application/PhabricatorApplicationAudit.php +++ b/src/applications/audit/application/PhabricatorApplicationAudit.php @@ -20,7 +20,7 @@ final class PhabricatorApplicationAudit extends PhabricatorApplication { public function getEventListeners() { return array( - new AuditPeopleMenuEventListener() + new AuditActionMenuEventListener() ); } diff --git a/src/applications/audit/events/AuditPeopleMenuEventListener.php b/src/applications/audit/events/AuditActionMenuEventListener.php similarity index 92% rename from src/applications/audit/events/AuditPeopleMenuEventListener.php rename to src/applications/audit/events/AuditActionMenuEventListener.php index 623ddc19a1..1cc4acb41e 100644 --- a/src/applications/audit/events/AuditPeopleMenuEventListener.php +++ b/src/applications/audit/events/AuditActionMenuEventListener.php @@ -1,6 +1,6 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS); diff --git a/src/applications/conpherence/application/PhabricatorApplicationConpherence.php b/src/applications/conpherence/application/PhabricatorApplicationConpherence.php index 719335fcf9..ba1bd34a7a 100644 --- a/src/applications/conpherence/application/PhabricatorApplicationConpherence.php +++ b/src/applications/conpherence/application/PhabricatorApplicationConpherence.php @@ -31,7 +31,7 @@ final class PhabricatorApplicationConpherence extends PhabricatorApplication { public function getEventListeners() { return array( - new ConpherencePeopleMenuEventListener(), + new ConpherenceActionMenuEventListener(), new ConpherenceHovercardEventListener(), ); } diff --git a/src/applications/conpherence/events/ConpherencePeopleMenuEventListener.php b/src/applications/conpherence/events/ConpherenceActionMenuEventListener.php similarity index 90% rename from src/applications/conpherence/events/ConpherencePeopleMenuEventListener.php rename to src/applications/conpherence/events/ConpherenceActionMenuEventListener.php index 70b5712d0b..60fdb20902 100644 --- a/src/applications/conpherence/events/ConpherencePeopleMenuEventListener.php +++ b/src/applications/conpherence/events/ConpherenceActionMenuEventListener.php @@ -1,6 +1,7 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS); diff --git a/src/applications/conpherence/events/ConpherenceHovercardEventListener.php b/src/applications/conpherence/events/ConpherenceHovercardEventListener.php index 759512fe7b..6020d6f7e0 100644 --- a/src/applications/conpherence/events/ConpherenceHovercardEventListener.php +++ b/src/applications/conpherence/events/ConpherenceHovercardEventListener.php @@ -8,7 +8,7 @@ * * @task event */ -final class ConpherenceHovercardEventListener extends PhutilEventListener { +final class ConpherenceHovercardEventListener extends PhabricatorEventListener { public function register() { $this->listen(PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD); diff --git a/src/applications/daemon/event/PhabricatorDaemonEventListener.php b/src/applications/daemon/event/PhabricatorDaemonEventListener.php index 1a65a15acc..4f6cc4e6e1 100644 --- a/src/applications/daemon/event/PhabricatorDaemonEventListener.php +++ b/src/applications/daemon/event/PhabricatorDaemonEventListener.php @@ -1,6 +1,6 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS); diff --git a/src/applications/differential/events/DifferentialHovercardEventListener.php b/src/applications/differential/events/DifferentialHovercardEventListener.php index 52d06168df..ae9fd0011b 100644 --- a/src/applications/differential/events/DifferentialHovercardEventListener.php +++ b/src/applications/differential/events/DifferentialHovercardEventListener.php @@ -1,6 +1,7 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD); diff --git a/src/applications/diffusion/events/DiffusionHovercardEventListener.php b/src/applications/diffusion/events/DiffusionHovercardEventListener.php index 8d10181771..ccba5c8260 100644 --- a/src/applications/diffusion/events/DiffusionHovercardEventListener.php +++ b/src/applications/diffusion/events/DiffusionHovercardEventListener.php @@ -1,6 +1,6 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD); diff --git a/src/applications/flag/events/PhabricatorFlagsUIEventListener.php b/src/applications/flag/events/PhabricatorFlagsUIEventListener.php index e9ca4d3066..9e54c12cd5 100644 --- a/src/applications/flag/events/PhabricatorFlagsUIEventListener.php +++ b/src/applications/flag/events/PhabricatorFlagsUIEventListener.php @@ -1,6 +1,6 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS); diff --git a/src/applications/maniphest/application/PhabricatorApplicationManiphest.php b/src/applications/maniphest/application/PhabricatorApplicationManiphest.php index 744c5c5113..234f1e2a3b 100644 --- a/src/applications/maniphest/application/PhabricatorApplicationManiphest.php +++ b/src/applications/maniphest/application/PhabricatorApplicationManiphest.php @@ -35,7 +35,7 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication { public function getEventListeners() { return array( new ManiphestNameIndexEventListener(), - new ManiphestPeopleMenuEventListener(), + new ManiphestActionMenuEventListener(), new ManiphestHovercardEventListener(), ); } diff --git a/src/applications/maniphest/event/ManiphestPeopleMenuEventListener.php b/src/applications/maniphest/event/ManiphestActionMenuEventListener.php similarity index 93% rename from src/applications/maniphest/event/ManiphestPeopleMenuEventListener.php rename to src/applications/maniphest/event/ManiphestActionMenuEventListener.php index fdb846fa5f..af3a4e17c5 100644 --- a/src/applications/maniphest/event/ManiphestPeopleMenuEventListener.php +++ b/src/applications/maniphest/event/ManiphestActionMenuEventListener.php @@ -1,6 +1,6 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS); diff --git a/src/applications/maniphest/event/ManiphestEdgeEventListener.php b/src/applications/maniphest/event/ManiphestEdgeEventListener.php index 89ef2599e4..d143acec50 100644 --- a/src/applications/maniphest/event/ManiphestEdgeEventListener.php +++ b/src/applications/maniphest/event/ManiphestEdgeEventListener.php @@ -7,7 +7,7 @@ * * @group maniphest */ -final class ManiphestEdgeEventListener extends PhutilEventListener { +final class ManiphestEdgeEventListener extends PhabricatorEventListener { private $edges = array(); private $tasks = array(); diff --git a/src/applications/maniphest/event/ManiphestHovercardEventListener.php b/src/applications/maniphest/event/ManiphestHovercardEventListener.php index 64f375662f..dab66739b9 100644 --- a/src/applications/maniphest/event/ManiphestHovercardEventListener.php +++ b/src/applications/maniphest/event/ManiphestHovercardEventListener.php @@ -1,6 +1,6 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD); diff --git a/src/applications/maniphest/event/ManiphestNameIndexEventListener.php b/src/applications/maniphest/event/ManiphestNameIndexEventListener.php index f064534d3d..089178b9a9 100644 --- a/src/applications/maniphest/event/ManiphestNameIndexEventListener.php +++ b/src/applications/maniphest/event/ManiphestNameIndexEventListener.php @@ -1,6 +1,6 @@ listen(PhabricatorEventType::TYPE_SEARCH_DIDUPDATEINDEX); diff --git a/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php b/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php index 7177b9cb97..31ebf778c2 100644 --- a/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php +++ b/src/applications/people/event/PhabricatorPeopleHovercardEventListener.php @@ -1,7 +1,7 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD); diff --git a/src/applications/phrequent/event/PhrequentUIEventListener.php b/src/applications/phrequent/event/PhrequentUIEventListener.php index aa934a39aa..0f5ad399a3 100644 --- a/src/applications/phrequent/event/PhrequentUIEventListener.php +++ b/src/applications/phrequent/event/PhrequentUIEventListener.php @@ -1,7 +1,7 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS); diff --git a/src/applications/phriction/event/PhrictionActionMenuEventListener.php b/src/applications/phriction/event/PhrictionActionMenuEventListener.php index 31e00a1e3f..43b72831fb 100644 --- a/src/applications/phriction/event/PhrictionActionMenuEventListener.php +++ b/src/applications/phriction/event/PhrictionActionMenuEventListener.php @@ -1,6 +1,6 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS); diff --git a/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php b/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php index 210a25d06a..aaf75766b0 100644 --- a/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php +++ b/src/applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php @@ -1,7 +1,7 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS); diff --git a/src/applications/tokens/event/PhabricatorTokenUIEventListener.php b/src/applications/tokens/event/PhabricatorTokenUIEventListener.php index 97da41b95f..166bb7b97c 100644 --- a/src/applications/tokens/event/PhabricatorTokenUIEventListener.php +++ b/src/applications/tokens/event/PhabricatorTokenUIEventListener.php @@ -1,7 +1,7 @@ listen(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS); diff --git a/src/infrastructure/events/PhabricatorEventEngine.php b/src/infrastructure/events/PhabricatorEventEngine.php index 8d49752d61..3f578d09df 100644 --- a/src/infrastructure/events/PhabricatorEventEngine.php +++ b/src/infrastructure/events/PhabricatorEventEngine.php @@ -26,6 +26,7 @@ final class PhabricatorEventEngine { foreach ($applications as $application) { $listeners = $application->getEventListeners(); foreach ($listeners as $listener) { + $listener->setApplication($application); $listener->register(); } } diff --git a/src/infrastructure/events/PhabricatorEventListener.php b/src/infrastructure/events/PhabricatorEventListener.php new file mode 100644 index 0000000000..9ffb26ace7 --- /dev/null +++ b/src/infrastructure/events/PhabricatorEventListener.php @@ -0,0 +1,36 @@ +application = $application; + return $this; + } + + public function getApplication() { + return $this->application; + } + + public function hasApplicationCapability( + PhabricatorUser $viewer, + $capability) { + return PhabricatorPolicyFilter::hasCapability( + $viewer, + $this->getApplication(), + $capability); + } + + public function canUseApplication(PhabricatorUser $viewer) { + return $this->hasApplicationCapability( + $viewer, + PhabricatorPolicyCapability::CAN_VIEW); + } + +} + + + + + diff --git a/src/infrastructure/events/PhabricatorExampleEventListener.php b/src/infrastructure/events/PhabricatorExampleEventListener.php index 7526490dc6..03c83d7146 100644 --- a/src/infrastructure/events/PhabricatorExampleEventListener.php +++ b/src/infrastructure/events/PhabricatorExampleEventListener.php @@ -6,7 +6,7 @@ * * @group events */ -final class PhabricatorExampleEventListener extends PhutilEventListener { +final class PhabricatorExampleEventListener extends PhabricatorEventListener { public function register() { // When your listener is installed, its register() method will be called.