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 edit Integration with Edit Views | ||||
| * @task view Integration with Property Views | * @task view Integration with Property Views | ||||
| * @task list Integration with List 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 xactionmail Integration with Transaction Mail | * @task xactionmail Integration with Transaction Mail | ||||
| * @task globalsearch Integration with Global Search | * @task globalsearch Integration with Global Search | ||||
| * @task herald Integration with Herald | |||||
| */ | */ | ||||
| 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_TRANSACTIONMAIL = 'ApplicationTransactions.mail'; | const ROLE_TRANSACTIONMAIL = 'ApplicationTransactions.mail'; | ||||
| 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'; | const ROLE_GLOBALSEARCH = 'GlobalSearch'; | ||||
| const ROLE_CONDUIT = 'conduit'; | const ROLE_CONDUIT = 'conduit'; | ||||
| const ROLE_HERALD = 'herald'; | |||||
| /* -( Building Applications with Custom Fields )--------------------------- */ | /* -( Building Applications with Custom Fields )--------------------------- */ | ||||
| /** | /** | ||||
| * @task apps | * @task apps | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | switch ($role) { | ||||
| case self::ROLE_LIST: | case self::ROLE_LIST: | ||||
| return $this->shouldAppearInListView(); | return $this->shouldAppearInListView(); | ||||
| case self::ROLE_GLOBALSEARCH: | case self::ROLE_GLOBALSEARCH: | ||||
| return $this->shouldAppearInGlobalSearch(); | return $this->shouldAppearInGlobalSearch(); | ||||
| case self::ROLE_CONDUIT: | case self::ROLE_CONDUIT: | ||||
| return $this->shouldAppearInConduitDictionary(); | return $this->shouldAppearInConduitDictionary(); | ||||
| case self::ROLE_TRANSACTIONMAIL: | case self::ROLE_TRANSACTIONMAIL: | ||||
| return $this->shouldAppearInTransactionMail(); | return $this->shouldAppearInTransactionMail(); | ||||
| case self::ROLE_HERALD: | |||||
| return $this->shouldAppearInHerald(); | |||||
| 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 973 Lines • ▼ Show 20 Lines | /* -( Conduit )------------------------------------------------------------ */ | ||||
| */ | */ | ||||
| public function getConduitDictionaryValue() { | public function getConduitDictionaryValue() { | ||||
| if ($this->proxy) { | if ($this->proxy) { | ||||
| return $this->proxy->getConduitDictionaryValue(); | return $this->proxy->getConduitDictionaryValue(); | ||||
| } | } | ||||
| throw new PhabricatorCustomFieldImplementationIncompleteException($this); | throw new PhabricatorCustomFieldImplementationIncompleteException($this); | ||||
| } | } | ||||
| /* -( Herald )------------------------------------------------------------- */ | |||||
| /** | |||||
| * Return `true` to make this field available in Herald. | |||||
| * | |||||
| * @return bool True to expose the field in Herald. | |||||
| * @task herald | |||||
| */ | |||||
| public function shouldAppearInHerald() { | |||||
| if ($this->proxy) { | |||||
| return $this->proxy->shouldAppearInHerald(); | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /** | |||||
| * Get the name of the field in Herald. By default, this uses the | |||||
| * normal field name. | |||||
| * | |||||
| * @return string Herald field name. | |||||
| * @task herald | |||||
| */ | |||||
| public function getHeraldFieldName() { | |||||
| if ($this->proxy) { | |||||
| return $this->proxy->getHeraldFieldName(); | |||||
| } | |||||
| return $this->getFieldName(); | |||||
| } | |||||
| /** | |||||
| * Get the field value for evaluation by Herald. | |||||
| * | |||||
| * @return wild Field value. | |||||
| * @task herald | |||||
| */ | |||||
| public function getHeraldFieldValue() { | |||||
| if ($this->proxy) { | |||||
| return $this->proxy->getHeraldFieldValue(); | |||||
| } | |||||
| throw new PhabricatorCustomFieldImplementationIncompleteException($this); | |||||
| } | |||||
| /** | |||||
| * Get the available conditions for this field in Herald. | |||||
| * | |||||
| * @return list<const> List of Herald condition constants. | |||||
| * @task herald | |||||
| */ | |||||
| public function getHeraldFieldConditions() { | |||||
| if ($this->proxy) { | |||||
| return $this->proxy->getHeraldFieldConditions(); | |||||
| } | |||||
| throw new PhabricatorCustomFieldImplementationIncompleteException($this); | |||||
| } | |||||
| /** | |||||
| * Get the Herald value type for the given condition. | |||||
| * | |||||
| * @param const Herald condition constant. | |||||
| * @return const|null Herald value type, or null to use the default. | |||||
| * @task herald | |||||
| */ | |||||
| public function getHeraldFieldValueType($condition) { | |||||
| if ($this->proxy) { | |||||
| return $this->proxy->getHeraldFieldValueType($condition); | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | } | ||||