Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/query/PhabricatorRepositoryQuery.php
| Show All 30 Lines | final class PhabricatorRepositoryQuery | ||||
| 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; | private $needURIs; | ||||
| private $needProfileImage; | |||||
| 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 108 Lines • ▼ Show 20 Lines | public function needProjectPHIDs($need_phids) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function needURIs($need_uris) { | public function needURIs($need_uris) { | ||||
| $this->needURIs = $need_uris; | $this->needURIs = $need_uris; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function needProfileImage($need) { | |||||
| $this->needProfileImage = $need; | |||||
| 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 198 Lines • ▼ Show 20 Lines | if ($this->needURIs) { | ||||
| ->execute(); | ->execute(); | ||||
| $uri_groups = mgroup($uris, 'getRepositoryPHID'); | $uri_groups = mgroup($uris, 'getRepositoryPHID'); | ||||
| foreach ($repositories as $repository) { | foreach ($repositories as $repository) { | ||||
| $repository_uris = idx($uri_groups, $repository->getPHID(), array()); | $repository_uris = idx($uri_groups, $repository->getPHID(), array()); | ||||
| $repository->attachURIs($repository_uris); | $repository->attachURIs($repository_uris); | ||||
| } | } | ||||
| } | } | ||||
| if ($this->needProfileImage) { | |||||
| $default = null; | |||||
| $file_phids = mpull($repositories, 'getProfileImagePHID'); | |||||
| $file_phids = array_filter($file_phids); | |||||
| if ($file_phids) { | |||||
| $files = id(new PhabricatorFileQuery()) | |||||
| ->setParentQuery($this) | |||||
| ->setViewer($this->getViewer()) | |||||
| ->withPHIDs($file_phids) | |||||
| ->execute(); | |||||
| $files = mpull($files, null, 'getPHID'); | |||||
| } else { | |||||
| $files = array(); | |||||
| } | |||||
| foreach ($repositories as $repository) { | |||||
| $file = idx($files, $repository->getProfileImagePHID()); | |||||
| if (!$file) { | |||||
| if (!$default) { | |||||
| $default = PhabricatorFile::loadBuiltin( | |||||
| $this->getViewer(), | |||||
| 'repo/code.png'); | |||||
| } | |||||
| $file = $default; | |||||
| } | |||||
| $repository->attachProfileImageFile($file); | |||||
| } | |||||
| } | |||||
| 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 318 Lines • Show Last 20 Lines | |||||