@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3abstract class DiffusionLowLevelQuery extends Phobject {
4
5 private $repository;
6
7 abstract protected function executeQuery();
8
9 public function setRepository(PhabricatorRepository $repository) {
10 $this->repository = $repository;
11 return $this;
12 }
13
14 public function getRepository() {
15 return $this->repository;
16 }
17
18 public function execute() {
19 if (!$this->getRepository()) {
20 throw new PhutilInvalidStateException('setRepository');
21 }
22
23 return $this->executeQuery();
24 }
25
26 protected function filterRefsByType(array $refs, array $types) {
27 $type_map = array_fuse($types);
28
29 foreach ($refs as $name => $ref_list) {
30 foreach ($ref_list as $key => $ref) {
31 if (empty($type_map[$ref['type']])) {
32 unset($refs[$name][$key]);
33 }
34 }
35 if (!$refs[$name]) {
36 unset($refs[$name]);
37 }
38 }
39
40 return $refs;
41 }
42
43}