3 final class PhabricatorProfileMenuItemConfigurationQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery
{
10 private $includeGlobal;
11 private $affectedObjectPHIDs;
13 public function withIDs(array $ids) {
18 public function withPHIDs(array $phids) {
19 $this->phids
= $phids;
23 public function withProfilePHIDs(array $phids) {
24 $this->profilePHIDs
= $phids;
28 public function withCustomPHIDs(array $phids, $include_global = false) {
29 $this->customPHIDs
= $phids;
30 $this->includeGlobal
= $include_global;
34 public function withAffectedObjectPHIDs(array $phids) {
35 $this->affectedObjectPHIDs
= $phids;
39 public function newResultObject() {
40 return new PhabricatorProfileMenuItemConfiguration();
43 protected function loadPage() {
44 return $this->loadStandardPage($this->newResultObject());
47 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
48 $where = parent
::buildWhereClauseParts($conn);
50 if ($this->ids
!== null) {
57 if ($this->phids
!== null) {
60 'config.phid IN (%Ls)',
64 if ($this->profilePHIDs
!== null) {
67 'config.profilePHID IN (%Ls)',
71 if ($this->customPHIDs
!== null) {
72 if ($this->customPHIDs
&& $this->includeGlobal
) {
75 'config.customPHID IN (%Ls) OR config.customPHID IS NULL',
77 } else if ($this->customPHIDs
) {
80 'config.customPHID IN (%Ls)',
85 'config.customPHID IS NULL');
89 if ($this->affectedObjectPHIDs
!== null) {
92 'affected.dst IN (%Ls)',
93 $this->affectedObjectPHIDs
);
99 protected function buildJoinClauseParts(AphrontDatabaseConnection
$conn) {
100 $joins = parent
::buildJoinClauseParts($conn);
102 if ($this->affectedObjectPHIDs
!== null) {
105 'JOIN %T affected ON affected.src = config.phid
106 AND affected.type = %d',
107 PhabricatorEdgeConfig
::TABLE_NAME_EDGE
,
108 PhabricatorProfileMenuItemAffectsObjectEdgeType
::EDGECONST
);
114 protected function willFilterPage(array $page) {
115 $items = PhabricatorProfileMenuItem
::getAllMenuItems();
116 foreach ($page as $key => $item) {
117 $item_type = idx($items, $item->getMenuItemKey());
119 $this->didRejectResult($item);
123 $item_type = clone $item_type;
124 $item_type->setViewer($this->getViewer());
125 $item->attachMenuItem($item_type);
132 $profile_phids = mpull($page, 'getProfilePHID');
134 $profiles = id(new PhabricatorObjectQuery())
135 ->setViewer($this->getViewer())
136 ->setParentQuery($this)
137 ->withPHIDs($profile_phids)
139 $profiles = mpull($profiles, null, 'getPHID');
141 foreach ($page as $key => $item) {
142 $profile = idx($profiles, $item->getProfilePHID());
144 $this->didRejectResult($item);
149 $item->attachProfileObject($profile);
155 public function getQueryApplicationClass() {
156 return 'PhabricatorSearchApplication';
159 protected function getPrimaryTableAlias() {