From 6b65c578c7349cfc7a78f4b6fa1f46b9924ac4c3 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 3 Mar 2015 10:39:43 -0800 Subject: [PATCH] Forbid construction of dashboard panels on various Phortune objects Summary: Fixes T7102. These panels don't work, aren't meaningful, and don't seem very useful. We could eventually support providing context to dashboards somehow ("merchant dashboard") but don't have much of an apparent need for this. Test Plan: - Tried to create cart/subscription/charge dashboard panels. - Unable to create new ones. - The ones from before the change show a relevant error now. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7102 Differential Revision: https://secure.phabricator.com/D11953 --- .../paneltype/PhabricatorDashboardQueryPanelType.php | 8 ++++++++ .../phortune/query/PhortuneCartSearchEngine.php | 5 +++++ .../phortune/query/PhortuneChargeSearchEngine.php | 5 +++++ .../phortune/query/PhortuneSubscriptionSearchEngine.php | 5 +++++ 4 files changed, 23 insertions(+) diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php b/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php index 1914ece0b9..c4b306fe6f 100644 --- a/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php +++ b/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php @@ -130,6 +130,14 @@ final class PhabricatorDashboardQueryPanelType $class)); } + if (!$engine->canUseInPanelContext()) { + throw new Exception( + pht( + 'Application search engines of class "%s" can not be used to build '. + 'dashboard panels.', + $class)); + } + return $engine; } diff --git a/src/applications/phortune/query/PhortuneCartSearchEngine.php b/src/applications/phortune/query/PhortuneCartSearchEngine.php index 83ef32b526..ef91dc47ae 100644 --- a/src/applications/phortune/query/PhortuneCartSearchEngine.php +++ b/src/applications/phortune/query/PhortuneCartSearchEngine.php @@ -7,6 +7,11 @@ final class PhortuneCartSearchEngine private $account; private $subscription; + public function canUseInPanelContext() { + // These only make sense in an account or merchant context. + return false; + } + public function setAccount(PhortuneAccount $account) { $this->account = $account; return $this; diff --git a/src/applications/phortune/query/PhortuneChargeSearchEngine.php b/src/applications/phortune/query/PhortuneChargeSearchEngine.php index 939eadd5c5..617c9641c9 100644 --- a/src/applications/phortune/query/PhortuneChargeSearchEngine.php +++ b/src/applications/phortune/query/PhortuneChargeSearchEngine.php @@ -5,6 +5,11 @@ final class PhortuneChargeSearchEngine private $account; + public function canUseInPanelContext() { + // These only make sense in an account context. + return false; + } + public function setAccount(PhortuneAccount $account) { $this->account = $account; return $this; diff --git a/src/applications/phortune/query/PhortuneSubscriptionSearchEngine.php b/src/applications/phortune/query/PhortuneSubscriptionSearchEngine.php index 0806197dd8..695cd24d0c 100644 --- a/src/applications/phortune/query/PhortuneSubscriptionSearchEngine.php +++ b/src/applications/phortune/query/PhortuneSubscriptionSearchEngine.php @@ -6,6 +6,11 @@ final class PhortuneSubscriptionSearchEngine private $merchant; private $account; + public function canUseInPanelContext() { + // These only make sense in an account or merchant context. + return false; + } + public function setAccount(PhortuneAccount $account) { $this->account = $account; return $this;