Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/storage/PhabricatorOwnersPackage.php
| Show All 14 Lines | final class PhabricatorOwnersPackage | ||||
| protected $name; | protected $name; | ||||
| protected $auditingEnabled; | protected $auditingEnabled; | ||||
| protected $autoReview; | protected $autoReview; | ||||
| protected $description; | protected $description; | ||||
| protected $status; | protected $status; | ||||
| protected $viewPolicy; | protected $viewPolicy; | ||||
| protected $editPolicy; | protected $editPolicy; | ||||
| protected $dominion; | protected $dominion; | ||||
| protected $properties = array(); | |||||
| private $paths = self::ATTACHABLE; | private $paths = self::ATTACHABLE; | ||||
| private $owners = self::ATTACHABLE; | private $owners = self::ATTACHABLE; | ||||
| private $customFields = self::ATTACHABLE; | private $customFields = self::ATTACHABLE; | ||||
| private $pathRepositoryMap = array(); | private $pathRepositoryMap = array(); | ||||
| const STATUS_ACTIVE = 'active'; | const STATUS_ACTIVE = 'active'; | ||||
| const STATUS_ARCHIVED = 'archived'; | const STATUS_ARCHIVED = 'archived'; | ||||
| const AUTOREVIEW_NONE = 'none'; | const AUTOREVIEW_NONE = 'none'; | ||||
| const AUTOREVIEW_SUBSCRIBE = 'subscribe'; | const AUTOREVIEW_SUBSCRIBE = 'subscribe'; | ||||
| const AUTOREVIEW_SUBSCRIBE_ALWAYS = 'subscribe-always'; | const AUTOREVIEW_SUBSCRIBE_ALWAYS = 'subscribe-always'; | ||||
| const AUTOREVIEW_REVIEW = 'review'; | const AUTOREVIEW_REVIEW = 'review'; | ||||
| const AUTOREVIEW_REVIEW_ALWAYS = 'review-always'; | const AUTOREVIEW_REVIEW_ALWAYS = 'review-always'; | ||||
| const AUTOREVIEW_BLOCK = 'block'; | const AUTOREVIEW_BLOCK = 'block'; | ||||
| const AUTOREVIEW_BLOCK_ALWAYS = 'block-always'; | const AUTOREVIEW_BLOCK_ALWAYS = 'block-always'; | ||||
| const DOMINION_STRONG = 'strong'; | const DOMINION_STRONG = 'strong'; | ||||
| const DOMINION_WEAK = 'weak'; | const DOMINION_WEAK = 'weak'; | ||||
| const PROPERTY_IGNORED = 'ignored'; | |||||
| public static function initializeNewPackage(PhabricatorUser $actor) { | public static function initializeNewPackage(PhabricatorUser $actor) { | ||||
| $app = id(new PhabricatorApplicationQuery()) | $app = id(new PhabricatorApplicationQuery()) | ||||
| ->setViewer($actor) | ->setViewer($actor) | ||||
| ->withClasses(array('PhabricatorOwnersApplication')) | ->withClasses(array('PhabricatorOwnersApplication')) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| $view_policy = $app->getPolicy( | $view_policy = $app->getPolicy( | ||||
| PhabricatorOwnersDefaultViewCapability::CAPABILITY); | PhabricatorOwnersDefaultViewCapability::CAPABILITY); | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | public static function getDominionOptionsMap() { | ||||
| ); | ); | ||||
| } | } | ||||
| protected function getConfiguration() { | protected function getConfiguration() { | ||||
| return array( | return array( | ||||
| // This information is better available from the history table. | // This information is better available from the history table. | ||||
| self::CONFIG_TIMESTAMPS => false, | self::CONFIG_TIMESTAMPS => false, | ||||
| self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
| self::CONFIG_SERIALIZATION => array( | |||||
| 'properties' => self::SERIALIZATION_JSON, | |||||
| ), | |||||
| self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
| 'name' => 'sort', | 'name' => 'sort', | ||||
| 'description' => 'text', | 'description' => 'text', | ||||
| 'auditingEnabled' => 'bool', | 'auditingEnabled' => 'bool', | ||||
| 'status' => 'text32', | 'status' => 'text32', | ||||
| 'autoReview' => 'text32', | 'autoReview' => 'text32', | ||||
| 'dominion' => 'text32', | 'dominion' => 'text32', | ||||
| ), | ), | ||||
| ) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
| } | } | ||||
| public function getPHIDType() { | public function getPHIDType() { | ||||
| return PhabricatorOwnersPackagePHIDType::TYPECONST; | return PhabricatorOwnersPackagePHIDType::TYPECONST; | ||||
| } | } | ||||
| public function isArchived() { | public function isArchived() { | ||||
| return ($this->getStatus() == self::STATUS_ARCHIVED); | return ($this->getStatus() == self::STATUS_ARCHIVED); | ||||
| } | } | ||||
| public function getMustMatchUngeneratedPaths() { | public function getMustMatchUngeneratedPaths() { | ||||
| // TODO: For now, there's no way to actually configure this. | $ignore_attributes = $this->getIgnoredPathAttributes(); | ||||
| return false; | return !empty($ignore_attributes['generated']); | ||||
| } | |||||
| public function getPackageProperty($key, $default = null) { | |||||
| return idx($this->properties, $key, $default); | |||||
| } | |||||
| public function setPackageProperty($key, $value) { | |||||
| $this->properties[$key] = $value; | |||||
| return $this; | |||||
| } | |||||
| public function getIgnoredPathAttributes() { | |||||
| return $this->getPackageProperty(self::PROPERTY_IGNORED, array()); | |||||
| } | |||||
| public function setIgnoredPathAttributes(array $attributes) { | |||||
| return $this->setPackageProperty(self::PROPERTY_IGNORED, $attributes); | |||||
| } | } | ||||
| public function loadOwners() { | public function loadOwners() { | ||||
| if (!$this->getID()) { | if (!$this->getID()) { | ||||
| return array(); | return array(); | ||||
| } | } | ||||
| return id(new PhabricatorOwnersOwner())->loadAllWhere( | return id(new PhabricatorOwnersOwner())->loadAllWhere( | ||||
| 'packageID = %d', | 'packageID = %d', | ||||
| ▲ Show 20 Lines • Show All 524 Lines • ▼ Show 20 Lines | return array( | ||||
| id(new PhabricatorConduitSearchFieldSpecification()) | id(new PhabricatorConduitSearchFieldSpecification()) | ||||
| ->setKey('audit') | ->setKey('audit') | ||||
| ->setType('map<string, wild>') | ->setType('map<string, wild>') | ||||
| ->setDescription(pht('Auto audit information.')), | ->setDescription(pht('Auto audit information.')), | ||||
| id(new PhabricatorConduitSearchFieldSpecification()) | id(new PhabricatorConduitSearchFieldSpecification()) | ||||
| ->setKey('dominion') | ->setKey('dominion') | ||||
| ->setType('map<string, wild>') | ->setType('map<string, wild>') | ||||
| ->setDescription(pht('Dominion setting information.')), | ->setDescription(pht('Dominion setting information.')), | ||||
| id(new PhabricatorConduitSearchFieldSpecification()) | |||||
| ->setKey('ignored') | |||||
| ->setType('map<string, wild>') | |||||
| ->setDescription(pht('Ignored attribute information.')), | |||||
| ); | ); | ||||
| } | } | ||||
| public function getFieldValuesForConduit() { | public function getFieldValuesForConduit() { | ||||
| $owner_list = array(); | $owner_list = array(); | ||||
| foreach ($this->getOwners() as $owner) { | foreach ($this->getOwners() as $owner) { | ||||
| $owner_list[] = array( | $owner_list[] = array( | ||||
| 'ownerPHID' => $owner->getUserPHID(), | 'ownerPHID' => $owner->getUserPHID(), | ||||
| Show All 37 Lines | public function getFieldValuesForConduit() { | ||||
| } | } | ||||
| $dominion = array( | $dominion = array( | ||||
| 'value' => $dominion_value, | 'value' => $dominion_value, | ||||
| 'label' => $dominion_label, | 'label' => $dominion_label, | ||||
| 'short' => $dominion_short, | 'short' => $dominion_short, | ||||
| ); | ); | ||||
| // Force this to always emit as a JSON object even if empty, never as | |||||
| // a JSON list. | |||||
| $ignored = $this->getIgnoredPathAttributes(); | |||||
| if (!$ignored) { | |||||
| $ignored = (object)array(); | |||||
| } | |||||
amckinley: Name this `$ignored` just so we don't accidentally clobber this variable later? | |||||
| return array( | return array( | ||||
| 'name' => $this->getName(), | 'name' => $this->getName(), | ||||
| 'description' => $this->getDescription(), | 'description' => $this->getDescription(), | ||||
| 'status' => $this->getStatus(), | 'status' => $this->getStatus(), | ||||
| 'owners' => $owner_list, | 'owners' => $owner_list, | ||||
| 'review' => $review, | 'review' => $review, | ||||
| 'audit' => $audit, | 'audit' => $audit, | ||||
| 'dominion' => $dominion, | 'dominion' => $dominion, | ||||
| 'ignored' => $ignored, | |||||
| ); | ); | ||||
| } | } | ||||
| public function getConduitSearchAttachments() { | public function getConduitSearchAttachments() { | ||||
| return array( | return array( | ||||
| id(new PhabricatorOwnersPathsSearchEngineAttachment()) | id(new PhabricatorOwnersPathsSearchEngineAttachment()) | ||||
| ->setAttachmentKey('paths'), | ->setAttachmentKey('paths'), | ||||
| ); | ); | ||||
| Show All 30 Lines | |||||
Name this $ignored just so we don't accidentally clobber this variable later?