Differential D17236 Diff 41453 src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
Show All 15 Lines | final class PhabricatorApplicationProfileMenuItem | ||||
} | } | ||||
public function canAddToObject($object) { | public function canAddToObject($object) { | ||||
return true; | return true; | ||||
} | } | ||||
public function getDisplayName( | public function getDisplayName( | ||||
PhabricatorProfileMenuItemConfiguration $config) { | PhabricatorProfileMenuItemConfiguration $config) { | ||||
$app = $this->getApplication($config); | $application = $this->getApplication($config); | ||||
if ($app) { | if (!$application) { | ||||
return $app->getName(); | return pht('(Restricted/Invalid Application)'); | ||||
} else { | } | ||||
return pht('(Uninstalled Application)'); | |||||
$name = $this->getName($config); | |||||
if (strlen($name)) { | |||||
return $name; | |||||
} | } | ||||
return $app->getName(); | |||||
return $application->getName(); | |||||
} | } | ||||
public function buildEditEngineFields( | public function buildEditEngineFields( | ||||
PhabricatorProfileMenuItemConfiguration $config) { | PhabricatorProfileMenuItemConfiguration $config) { | ||||
return array( | return array( | ||||
id(new PhabricatorDatasourceEditField()) | id(new PhabricatorDatasourceEditField()) | ||||
->setKey(self::FIELD_APPLICATION) | ->setKey(self::FIELD_APPLICATION) | ||||
->setLabel(pht('Application')) | ->setLabel(pht('Application')) | ||||
->setIsRequired(true) | ->setIsRequired(true) | ||||
->setDatasource(new PhabricatorApplicationDatasource()) | ->setDatasource(new PhabricatorApplicationDatasource()) | ||||
->setIsRequired(true) | ->setIsRequired(true) | ||||
->setSingleValue($config->getMenuItemProperty('application')), | ->setSingleValue($config->getMenuItemProperty('application')), | ||||
id(new PhabricatorTextEditField()) | |||||
->setKey('name') | |||||
->setLabel(pht('Name')) | |||||
->setValue($this->getName($config)), | |||||
); | ); | ||||
} | } | ||||
private function getName( | |||||
PhabricatorProfileMenuItemConfiguration $config) { | |||||
return $config->getMenuItemProperty('name'); | |||||
} | |||||
private function getApplication( | private function getApplication( | ||||
PhabricatorProfileMenuItemConfiguration $config) { | PhabricatorProfileMenuItemConfiguration $config) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$phid = $config->getMenuItemProperty('application'); | $phid = $config->getMenuItemProperty('application'); | ||||
$app = id(new PhabricatorApplicationQuery()) | $app = id(new PhabricatorApplicationQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withPHIDs(array($phid)) | ->withPHIDs(array($phid)) | ||||
Show All 14 Lines | $is_installed = PhabricatorApplication::isClassInstalledForViewer( | ||||
get_class($app), | get_class($app), | ||||
$viewer); | $viewer); | ||||
if (!$is_installed) { | if (!$is_installed) { | ||||
return array(); | return array(); | ||||
} | } | ||||
$item = $this->newItem() | $item = $this->newItem() | ||||
->setHref($app->getApplicationURI()) | ->setHref($app->getApplicationURI()) | ||||
->setName($app->getName()) | ->setName($this->getDisplayName($config)) | ||||
->setIcon($app->getIcon()); | ->setIcon($app->getIcon()); | ||||
return array( | return array( | ||||
$item, | $item, | ||||
); | ); | ||||
} | } | ||||
public function validateTransactions( | public function validateTransactions( | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |