Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/storage/PhabricatorOwnersPackage.php
Show All 20 Lines | final class PhabricatorOwnersPackage | ||||
protected $status; | protected $status; | ||||
protected $viewPolicy; | protected $viewPolicy; | ||||
protected $editPolicy; | protected $editPolicy; | ||||
protected $dominion; | protected $dominion; | ||||
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(); | |||||
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_REVIEW = 'review'; | const AUTOREVIEW_REVIEW = 'review'; | ||||
const AUTOREVIEW_BLOCK = 'block'; | const AUTOREVIEW_BLOCK = 'block'; | ||||
▲ Show 20 Lines • Show All 327 Lines • ▼ Show 20 Lines | public static function splitPath($path) { | ||||
$result[] = '/'; | $result[] = '/'; | ||||
return array_reverse($result); | return array_reverse($result); | ||||
} | } | ||||
public function attachPaths(array $paths) { | public function attachPaths(array $paths) { | ||||
assert_instances_of($paths, 'PhabricatorOwnersPath'); | assert_instances_of($paths, 'PhabricatorOwnersPath'); | ||||
$this->paths = $paths; | $this->paths = $paths; | ||||
// Drop this cache if we're attaching new paths. | |||||
$this->pathRepositoryMap = array(); | |||||
return $this; | return $this; | ||||
} | } | ||||
public function getPaths() { | public function getPaths() { | ||||
return $this->assertAttached($this->paths); | return $this->assertAttached($this->paths); | ||||
} | } | ||||
public function getPathsForRepository($repository_phid) { | |||||
if (isset($this->pathRepositoryMap[$repository_phid])) { | |||||
return $this->pathRepositoryMap[$repository_phid]; | |||||
} | |||||
$map = array(); | |||||
foreach ($this->getPaths() as $path) { | |||||
if ($path->getRepositoryPHID() == $repository_phid) { | |||||
$map[] = $path; | |||||
} | |||||
} | |||||
$this->pathRepositoryMap[$repository_phid] = $map; | |||||
return $this->pathRepositoryMap[$repository_phid]; | |||||
} | |||||
public function attachOwners(array $owners) { | public function attachOwners(array $owners) { | ||||
assert_instances_of($owners, 'PhabricatorOwnersOwner'); | assert_instances_of($owners, 'PhabricatorOwnersOwner'); | ||||
$this->owners = $owners; | $this->owners = $owners; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getOwners() { | public function getOwners() { | ||||
return $this->assertAttached($this->owners); | return $this->assertAttached($this->owners); | ||||
▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines |