Differential D20398 Diff 48689 src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php
| <?php | <?php | ||||
| final class PhabricatorProfileMenuItemConfiguration | final class PhabricatorProfileMenuItemConfiguration | ||||
| extends PhabricatorSearchDAO | extends PhabricatorSearchDAO | ||||
| implements | implements | ||||
| PhabricatorPolicyInterface, | PhabricatorPolicyInterface, | ||||
| PhabricatorExtendedPolicyInterface, | PhabricatorExtendedPolicyInterface, | ||||
| PhabricatorApplicationTransactionInterface { | PhabricatorApplicationTransactionInterface, | ||||
| PhabricatorIndexableInterface { | |||||
| protected $profilePHID; | protected $profilePHID; | ||||
| protected $menuItemKey; | protected $menuItemKey; | ||||
| protected $builtinKey; | protected $builtinKey; | ||||
| protected $menuItemOrder; | protected $menuItemOrder; | ||||
| protected $visibility; | protected $visibility; | ||||
| protected $customPHID; | protected $customPHID; | ||||
| protected $menuItemProperties = array(); | protected $menuItemProperties = array(); | ||||
| ▲ Show 20 Lines • Show All 233 Lines • ▼ Show 20 Lines | public function matchesIdentifier($identifier) { | ||||
| if ((string)$this->getBuiltinKey() === (string)$identifier) { | if ((string)$this->getBuiltinKey() === (string)$identifier) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| public function getAffectedObjectPHIDs() { | |||||
| return $this->getMenuItem()->getAffectedObjectPHIDs($this); | |||||
| } | |||||
| public function getProfileMenuTypeDescription() { | |||||
| $profile_phid = $this->getProfilePHID(); | |||||
| $home_phid = id(new PhabricatorHomeApplication())->getPHID(); | |||||
| if ($profile_phid === $home_phid) { | |||||
| return pht('Home Menu'); | |||||
| } | |||||
| $favorites_phid = id(new PhabricatorFavoritesApplication())->getPHID(); | |||||
| if ($profile_phid === $favorites_phid) { | |||||
| return pht('Favorites Menu'); | |||||
| } | |||||
| switch (phid_get_type($profile_phid)) { | |||||
| case PhabricatorProjectProjectPHIDType::TYPECONST: | |||||
| return pht('Project Menu'); | |||||
| case PhabricatorDashboardPortalPHIDType::TYPECONST: | |||||
| return pht('Portal Menu'); | |||||
| } | |||||
| return pht('Profile Menu'); | |||||
| } | |||||
| public function newUsageSortVector() { | |||||
| // Used to sort items in contexts where we're showing the usage of an | |||||
| // object in menus, like "Dashboard Used By" on Dashboard pages. | |||||
| // Sort usage as a custom item after usage as a global item. | |||||
| if ($this->getCustomPHID()) { | |||||
| $is_personal = 1; | |||||
| } else { | |||||
| $is_personal = 0; | |||||
| } | |||||
| return id(new PhutilSortVector()) | |||||
| ->addInt($is_personal) | |||||
| ->addInt($this->getID()); | |||||
| } | |||||
| /* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
| public function getCapabilities() { | public function getCapabilities() { | ||||
| return array( | return array( | ||||
| PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
| PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
| ▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines | |||||