Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/storage/PhabricatorOwnersPackage.php
Show All 15 Lines | final class PhabricatorOwnersPackage | ||||
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(); | protected $properties = array(); | ||||
protected $auditingState; | protected $auditingState; | ||||
protected $authorityMode; | |||||
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 AUTHORITY_STRONG = 'strong'; | |||||
const AUTHORITY_WEAK = 'weak'; | |||||
const PROPERTY_IGNORED = 'ignored'; | 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); | ||||
$edit_policy = $app->getPolicy( | $edit_policy = $app->getPolicy( | ||||
PhabricatorOwnersDefaultEditCapability::CAPABILITY); | PhabricatorOwnersDefaultEditCapability::CAPABILITY); | ||||
return id(new PhabricatorOwnersPackage()) | return id(new PhabricatorOwnersPackage()) | ||||
->setAuditingState(PhabricatorOwnersAuditRule::AUDITING_NONE) | ->setAuditingState(PhabricatorOwnersAuditRule::AUDITING_NONE) | ||||
->setAutoReview(self::AUTOREVIEW_NONE) | ->setAutoReview(self::AUTOREVIEW_NONE) | ||||
->setDominion(self::DOMINION_STRONG) | ->setDominion(self::DOMINION_STRONG) | ||||
->setAuthorityMode(self::AUTHORITY_STRONG) | |||||
->setViewPolicy($view_policy) | ->setViewPolicy($view_policy) | ||||
->setEditPolicy($edit_policy) | ->setEditPolicy($edit_policy) | ||||
->attachPaths(array()) | ->attachPaths(array()) | ||||
->setStatus(self::STATUS_ACTIVE) | ->setStatus(self::STATUS_ACTIVE) | ||||
->attachOwners(array()) | ->attachOwners(array()) | ||||
->setDescription(''); | ->setDescription(''); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | return array( | ||||
), | ), | ||||
self::DOMINION_WEAK => array( | self::DOMINION_WEAK => array( | ||||
'name' => pht('Weak (Control Unowned Paths)'), | 'name' => pht('Weak (Control Unowned Paths)'), | ||||
'short' => pht('Weak'), | 'short' => pht('Weak'), | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
public static function getAuthorityOptionsMap() { | |||||
return array( | |||||
self::AUTHORITY_STRONG => array( | |||||
'name' => pht('Strong (Package Owns Paths)'), | |||||
'short' => pht('Strong'), | |||||
), | |||||
self::AUTHORITY_WEAK => array( | |||||
'name' => pht('Weak (Package Watches Paths)'), | |||||
'short' => pht('Weak'), | |||||
), | |||||
); | |||||
} | |||||
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( | self::CONFIG_SERIALIZATION => array( | ||||
'properties' => self::SERIALIZATION_JSON, | 'properties' => self::SERIALIZATION_JSON, | ||||
), | ), | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'name' => 'sort', | 'name' => 'sort', | ||||
'description' => 'text', | 'description' => 'text', | ||||
'auditingState' => 'text32', | 'auditingState' => 'text32', | ||||
'status' => 'text32', | 'status' => 'text32', | ||||
'autoReview' => 'text32', | 'autoReview' => 'text32', | ||||
'dominion' => 'text32', | 'dominion' => 'text32', | ||||
'authorityMode' => 'text32', | |||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function getPHIDType() { | public function getPHIDType() { | ||||
return PhabricatorOwnersPackagePHIDType::TYPECONST; | return PhabricatorOwnersPackagePHIDType::TYPECONST; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | public function getURI() { | ||||
// TODO: Move these to "/O123" for consistency. | // TODO: Move these to "/O123" for consistency. | ||||
return '/owners/package/'.$this->getID().'/'; | return '/owners/package/'.$this->getID().'/'; | ||||
} | } | ||||
public function newAuditingRule() { | public function newAuditingRule() { | ||||
return PhabricatorOwnersAuditRule::newFromState($this->getAuditingState()); | return PhabricatorOwnersAuditRule::newFromState($this->getAuditingState()); | ||||
} | } | ||||
public function getHasStrongAuthority() { | |||||
return ($this->getAuthorityMode() === self::AUTHORITY_STRONG); | |||||
} | |||||
/* -( 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 113 Lines • ▼ Show 20 Lines | return array( | ||||
->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()) | id(new PhabricatorConduitSearchFieldSpecification()) | ||||
->setKey('authority') | |||||
->setType('map<string, wild>') | |||||
->setDescription(pht('Authority setting information.')), | |||||
id(new PhabricatorConduitSearchFieldSpecification()) | |||||
->setKey('ignored') | ->setKey('ignored') | ||||
->setType('map<string, wild>') | ->setType('map<string, wild>') | ||||
->setDescription(pht('Ignored attribute information.')), | ->setDescription(pht('Ignored attribute information.')), | ||||
); | ); | ||||
} | } | ||||
public function getFieldValuesForConduit() { | public function getFieldValuesForConduit() { | ||||
$owner_list = array(); | $owner_list = array(); | ||||
Show All 34 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, | ||||
); | ); | ||||
$authority_value = $this->getAuthorityMode(); | |||||
$authority_map = self::getAuthorityOptionsMap(); | |||||
if (isset($authority_map[$authority_value])) { | |||||
$authority_label = $authority_map[$authority_value]['name']; | |||||
$authority_short = $authority_map[$authority_value]['short']; | |||||
} else { | |||||
$authority_label = pht('Unknown ("%s")', $authority_value); | |||||
$authority_short = pht('Unknown ("%s")', $authority_value); | |||||
} | |||||
$authority = array( | |||||
'value' => $authority_value, | |||||
'label' => $authority_label, | |||||
'short' => $authority_short, | |||||
); | |||||
// Force this to always emit as a JSON object even if empty, never as | // Force this to always emit as a JSON object even if empty, never as | ||||
// a JSON list. | // a JSON list. | ||||
$ignored = $this->getIgnoredPathAttributes(); | $ignored = $this->getIgnoredPathAttributes(); | ||||
if (!$ignored) { | if (!$ignored) { | ||||
$ignored = (object)array(); | $ignored = (object)array(); | ||||
} | } | ||||
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, | ||||
'authority' => $authority, | |||||
'ignored' => $ignored, | 'ignored' => $ignored, | ||||
); | ); | ||||
} | } | ||||
public function getConduitSearchAttachments() { | public function getConduitSearchAttachments() { | ||||
return array( | return array( | ||||
id(new PhabricatorOwnersPathsSearchEngineAttachment()) | id(new PhabricatorOwnersPathsSearchEngineAttachment()) | ||||
->setAttachmentKey('paths'), | ->setAttachmentKey('paths'), | ||||
Show All 31 Lines |