Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/engine/PhabricatorProfileMenuEngine.php
<?php | <?php | ||||
abstract class PhabricatorProfileMenuEngine extends Phobject { | abstract class PhabricatorProfileMenuEngine extends Phobject { | ||||
private $viewer; | private $viewer; | ||||
private $profileObject; | private $profileObject; | ||||
private $customPHID; | |||||
private $items; | private $items; | ||||
private $defaultItem; | private $defaultItem; | ||||
private $controller; | private $controller; | ||||
private $navigation; | private $navigation; | ||||
public function setViewer(PhabricatorUser $viewer) { | public function setViewer(PhabricatorUser $viewer) { | ||||
$this->viewer = $viewer; | $this->viewer = $viewer; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getViewer() { | public function getViewer() { | ||||
return $this->viewer; | return $this->viewer; | ||||
} | } | ||||
public function setProfileObject($profile_object) { | public function setProfileObject($profile_object) { | ||||
$this->profileObject = $profile_object; | $this->profileObject = $profile_object; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getProfileObject() { | public function getProfileObject() { | ||||
return $this->profileObject; | return $this->profileObject; | ||||
} | } | ||||
public function setCustomPHID($custom_phid) { | |||||
$this->customPHID = $custom_phid; | |||||
return $this; | |||||
} | |||||
public function getCustomPHID() { | |||||
return $this->customPHID; | |||||
} | |||||
public function setController(PhabricatorController $controller) { | public function setController(PhabricatorController $controller) { | ||||
$this->controller = $controller; | $this->controller = $controller; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getController() { | public function getController() { | ||||
return $this->controller; | return $this->controller; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | abstract class PhabricatorProfileMenuEngine extends Phobject { | ||||
} | } | ||||
private function loadItems() { | private function loadItems() { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$object = $this->getProfileObject(); | $object = $this->getProfileObject(); | ||||
$items = $this->loadBuiltinProfileItems(); | $items = $this->loadBuiltinProfileItems(); | ||||
if ($this->getCustomPHID()) { | |||||
epriestley: I expect this will fatal when there is no `customObject`, because you will query by… | |||||
Done Inline ActionsYeah, I thought it should too, seems like ... it's not fataling the page, but adding custom items doesn't work. Let me see, maybe I uploaded old revision chad: Yeah, I thought it should too, seems like ... it's not fataling the page, but adding custom… | |||||
$stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery()) | $stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withProfilePHIDs(array($object->getPHID())) | ->withProfilePHIDs(array($object->getPHID())) | ||||
->withCustomPHIDs(array($this->getCustomPHID())) | |||||
->execute(); | ->execute(); | ||||
} else { | |||||
$stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery()) | |||||
->setViewer($viewer) | |||||
->withProfilePHIDs(array($object->getPHID())) | |||||
->execute(); | |||||
Not Done Inline ActionsThis is fine for now, but just note that it will load the global config and all custom config for all users. epriestley: This is fine for now, but just note that it will load the global config //and// all custom… | |||||
Not Done Inline Actionsoh right chad: oh right | |||||
} | |||||
foreach ($stored_items as $stored_item) { | foreach ($stored_items as $stored_item) { | ||||
$impl = $stored_item->getMenuItem(); | $impl = $stored_item->getMenuItem(); | ||||
$impl->setViewer($viewer); | $impl->setViewer($viewer); | ||||
} | } | ||||
// Merge the stored items into the builtin items. If a builtin item has | // Merge the stored items into the builtin items. If a builtin item has | ||||
// a stored version, replace the defaults with the stored changes. | // a stored version, replace the defaults with the stored changes. | ||||
▲ Show 20 Lines • Show All 734 Lines • Show Last 20 Lines |
I expect this will fatal when there is no customObject, because you will query by withCustomPHIDs(array()), which will resolve to a %Ls on array() and fatal ("%Ls conversion must have at least one element in the array you pass").
Instead, add this constraint only if there is a custom object.