Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/query/PhabricatorRepositoryQuery.php
Show All 28 Lines | final class PhabricatorRepositoryQuery | ||||
const HOSTED_PHABRICATOR = 'hosted-phab'; | const HOSTED_PHABRICATOR = 'hosted-phab'; | ||||
const HOSTED_REMOTE = 'hosted-remote'; | const HOSTED_REMOTE = 'hosted-remote'; | ||||
const HOSTED_ALL = 'hosted-all'; | const HOSTED_ALL = 'hosted-all'; | ||||
private $hosted = self::HOSTED_ALL; | private $hosted = self::HOSTED_ALL; | ||||
private $needMostRecentCommits; | private $needMostRecentCommits; | ||||
private $needCommitCounts; | private $needCommitCounts; | ||||
private $needProjectPHIDs; | private $needProjectPHIDs; | ||||
private $needURIs; | |||||
public function withIDs(array $ids) { | public function withIDs(array $ids) { | ||||
$this->ids = $ids; | $this->ids = $ids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withPHIDs(array $phids) { | public function withPHIDs(array $phids) { | ||||
$this->phids = $phids; | $this->phids = $phids; | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | public function needMostRecentCommits($need_commits) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needProjectPHIDs($need_phids) { | public function needProjectPHIDs($need_phids) { | ||||
$this->needProjectPHIDs = $need_phids; | $this->needProjectPHIDs = $need_phids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needURIs($need_uris) { | |||||
$this->needURIs = $need_uris; | |||||
return $this; | |||||
} | |||||
public function getBuiltinOrders() { | public function getBuiltinOrders() { | ||||
return array( | return array( | ||||
'committed' => array( | 'committed' => array( | ||||
'vector' => array('committed', 'id'), | 'vector' => array('committed', 'id'), | ||||
'name' => pht('Most Recent Commit'), | 'name' => pht('Most Recent Commit'), | ||||
), | ), | ||||
'name' => array( | 'name' => array( | ||||
'vector' => array('name', 'id'), | 'vector' => array('name', 'id'), | ||||
▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | if ($this->needProjectPHIDs) { | ||||
$project_phids = $edge_query->getDestinationPHIDs( | $project_phids = $edge_query->getDestinationPHIDs( | ||||
array( | array( | ||||
$repository->getPHID(), | $repository->getPHID(), | ||||
)); | )); | ||||
$repository->attachProjectPHIDs($project_phids); | $repository->attachProjectPHIDs($project_phids); | ||||
} | } | ||||
} | } | ||||
$viewer = $this->getViewer(); | |||||
if ($this->needURIs) { | |||||
$uris = id(new PhabricatorRepositoryURIQuery()) | |||||
->setViewer($viewer) | |||||
->withRepositories($repositories) | |||||
->execute(); | |||||
$uri_groups = mgroup($uris, 'getRepositoryPHID'); | |||||
foreach ($repositories as $repository) { | |||||
$repository_uris = idx($uri_groups, $repository->getPHID(), array()); | |||||
$repository->attachURIs($repository_uris); | |||||
} | |||||
} | |||||
return $repositories; | return $repositories; | ||||
} | } | ||||
protected function getPrimaryTableAlias() { | protected function getPrimaryTableAlias() { | ||||
return 'r'; | return 'r'; | ||||
} | } | ||||
public function getOrderableColumns() { | public function getOrderableColumns() { | ||||
▲ Show 20 Lines • Show All 315 Lines • Show Last 20 Lines |