Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/customfield/field/PhabricatorCustomField.php
| <?php | <?php | ||||
| /** | /** | ||||
| * @task apps Building Applications with Custom Fields | * @task apps Building Applications with Custom Fields | ||||
| * @task core Core Properties and Field Identity | * @task core Core Properties and Field Identity | ||||
| * @task proxy Field Proxies | * @task proxy Field Proxies | ||||
| * @task context Contextual Data | * @task context Contextual Data | ||||
| * @task storage Field Storage | * @task storage Field Storage | ||||
| * @task edit Integration with Edit Views | |||||
| * @task view Integration with Property Views | |||||
| * @task list Integration with List views | |||||
| * @task appsearch Integration with ApplicationSearch | * @task appsearch Integration with ApplicationSearch | ||||
| * @task appxaction Integration with ApplicationTransactions | * @task appxaction Integration with ApplicationTransactions | ||||
| * @task edit Integration with edit views | * @task globalsearch Integration with Global Search | ||||
| * @task view Integration with property views | |||||
| * @task list Integration with list views | |||||
| */ | */ | ||||
| abstract class PhabricatorCustomField { | abstract class PhabricatorCustomField { | ||||
| private $viewer; | private $viewer; | ||||
| private $object; | private $object; | ||||
| private $proxy; | private $proxy; | ||||
| const ROLE_APPLICATIONTRANSACTIONS = 'ApplicationTransactions'; | const ROLE_APPLICATIONTRANSACTIONS = 'ApplicationTransactions'; | ||||
| const ROLE_APPLICATIONSEARCH = 'ApplicationSearch'; | const ROLE_APPLICATIONSEARCH = 'ApplicationSearch'; | ||||
| const ROLE_STORAGE = 'storage'; | const ROLE_STORAGE = 'storage'; | ||||
| const ROLE_DEFAULT = 'default'; | const ROLE_DEFAULT = 'default'; | ||||
| const ROLE_EDIT = 'edit'; | const ROLE_EDIT = 'edit'; | ||||
| const ROLE_VIEW = 'view'; | const ROLE_VIEW = 'view'; | ||||
| const ROLE_LIST = 'list'; | const ROLE_LIST = 'list'; | ||||
| const ROLE_GLOBALSEARCH = 'GlobalSearch'; | |||||
| /* -( Building Applications with Custom Fields )--------------------------- */ | /* -( Building Applications with Custom Fields )--------------------------- */ | ||||
| /** | /** | ||||
| * @task apps | * @task apps | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | switch ($role) { | ||||
| case self::ROLE_STORAGE: | case self::ROLE_STORAGE: | ||||
| return $this->shouldUseStorage(); | return $this->shouldUseStorage(); | ||||
| case self::ROLE_EDIT: | case self::ROLE_EDIT: | ||||
| return $this->shouldAppearInEditView(); | return $this->shouldAppearInEditView(); | ||||
| case self::ROLE_VIEW: | case self::ROLE_VIEW: | ||||
| return $this->shouldAppearInPropertyView(); | return $this->shouldAppearInPropertyView(); | ||||
| case self::ROLE_LIST: | case self::ROLE_LIST: | ||||
| return $this->shouldAppearInListView(); | return $this->shouldAppearInListView(); | ||||
| case self::ROLE_GLOBALSEARCH: | |||||
| return $this->shouldAppearInGlobalSearch(); | |||||
| case self::ROLE_DEFAULT: | case self::ROLE_DEFAULT: | ||||
| return true; | return true; | ||||
| default: | default: | ||||
| throw new Exception("Unknown field role '{$role}'!"); | throw new Exception("Unknown field role '{$role}'!"); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 822 Lines • ▼ Show 20 Lines | /* -( List View )---------------------------------------------------------- */ | ||||
| public function renderOnListItem(PHUIObjectItemView $view) { | public function renderOnListItem(PHUIObjectItemView $view) { | ||||
| if ($this->proxy) { | if ($this->proxy) { | ||||
| return $this->proxy->renderOnListItem($view); | return $this->proxy->renderOnListItem($view); | ||||
| } | } | ||||
| throw new PhabricatorCustomFieldImplementationIncompleteException($this); | throw new PhabricatorCustomFieldImplementationIncompleteException($this); | ||||
| } | } | ||||
| /* -( Global Search )------------------------------------------------------ */ | |||||
| /** | |||||
| * @task globalsearch | |||||
| */ | |||||
| public function shouldAppearInGlobalSearch() { | |||||
| if ($this->proxy) { | |||||
| return $this->proxy->shouldAppearInGlobalSearch(); | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /** | |||||
| * @task globalsearch | |||||
| */ | |||||
| public function updateAbstractDocument( | |||||
| PhabricatorSearchAbstractDocument $document) { | |||||
| if ($this->proxy) { | |||||
| return $this->proxy->updateAbstractDocument($document); | |||||
| } | |||||
| return $document; | |||||
| } | |||||
| } | } | ||||