3 final class PhabricatorRepositoryURIQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery
{
8 private $repositoryPHIDs;
9 private $repositories = array();
11 public function withIDs(array $ids) {
16 public function withPHIDs(array $phids) {
17 $this->phids
= $phids;
21 public function withRepositoryPHIDs(array $phids) {
22 $this->repositoryPHIDs
= $phids;
26 public function withRepositories(array $repositories) {
27 $repositories = mpull($repositories, null, 'getPHID');
28 $this->withRepositoryPHIDs(array_keys($repositories));
29 $this->repositories
= $repositories;
33 public function newResultObject() {
34 return new PhabricatorRepositoryURI();
37 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
38 $where = parent
::buildWhereClauseParts($conn);
40 if ($this->ids
!== null) {
47 if ($this->phids
!== null) {
54 if ($this->repositoryPHIDs
!== null) {
57 'repositoryPHID IN (%Ls)',
58 $this->repositoryPHIDs
);
64 protected function willFilterPage(array $uris) {
65 $repositories = $this->repositories
;
67 $repository_phids = mpull($uris, 'getRepositoryPHID');
68 $repository_phids = array_fuse($repository_phids);
69 $repository_phids = array_diff_key($repository_phids, $repositories);
71 if ($repository_phids) {
72 $more_repositories = id(new PhabricatorRepositoryQuery())
73 ->setViewer($this->getViewer())
74 ->withPHIDs($repository_phids)
76 $repositories +
= mpull($more_repositories, null, 'getPHID');
79 foreach ($uris as $key => $uri) {
80 $repository_phid = $uri->getRepositoryPHID();
81 $repository = idx($repositories, $repository_phid);
83 $this->didRejectResult($uri);
87 $uri->attachRepository($repository);
93 public function getQueryApplicationClass() {
94 return 'PhabricatorDiffusionApplication';