1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-17 20:32:41 +01:00

Add CustomPHID to PhabricatorProfileMenuEngineConfiguration

Summary: Ref T5867, adds a customPHID field, nullable, and lets you query by it... i think? Not fully able to grok all the EditEngine stuff, but I think this is the right place for the query.

Test Plan: Not wired to anything, but pulling up project menu, editing, all still works.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T5867

Differential Revision: https://secure.phabricator.com/D17149
This commit is contained in:
Chad Little 2017-01-06 20:12:57 -08:00
parent 363084d4fa
commit 8a85ee7c15
5 changed files with 49 additions and 4 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_search.search_profilepanelconfiguration
ADD customPHID VARBINARY(64);

View file

@ -7,6 +7,7 @@ final class PhabricatorProfileMenuEditEngine
private $menuEngine; private $menuEngine;
private $profileObject; private $profileObject;
private $customPHID;
private $newMenuItemConfiguration; private $newMenuItemConfiguration;
private $isBuiltin; private $isBuiltin;
@ -32,6 +33,15 @@ final class PhabricatorProfileMenuEditEngine
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 setNewMenuItemConfiguration( public function setNewMenuItemConfiguration(
PhabricatorProfileMenuItemConfiguration $configuration) { PhabricatorProfileMenuItemConfiguration $configuration) {
$this->newMenuItemConfiguration = $configuration; $this->newMenuItemConfiguration = $configuration;

View file

@ -4,6 +4,7 @@ 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;
@ -27,6 +28,15 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
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;
@ -244,10 +254,18 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
$items = $this->loadBuiltinProfileItems(); $items = $this->loadBuiltinProfileItems();
$stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery()) if ($this->getCustomPHID()) {
->setViewer($viewer) $stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery())
->withProfilePHIDs(array($object->getPHID())) ->setViewer($viewer)
->execute(); ->withProfilePHIDs(array($object->getPHID()))
->withCustomPHIDs(array($this->getCustomPHID()))
->execute();
} else {
$stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery())
->setViewer($viewer)
->withProfilePHIDs(array($object->getPHID()))
->execute();
}
foreach ($stored_items as $stored_item) { foreach ($stored_items as $stored_item) {
$impl = $stored_item->getMenuItem(); $impl = $stored_item->getMenuItem();

View file

@ -6,6 +6,7 @@ final class PhabricatorProfileMenuItemConfigurationQuery
private $ids; private $ids;
private $phids; private $phids;
private $profilePHIDs; private $profilePHIDs;
private $customPHIDs;
public function withIDs(array $ids) { public function withIDs(array $ids) {
$this->ids = $ids; $this->ids = $ids;
@ -22,6 +23,11 @@ final class PhabricatorProfileMenuItemConfigurationQuery
return $this; return $this;
} }
public function withCustomPHIDs(array $phids) {
$this->customPHIDs = $phids;
return $this;
}
public function newResultObject() { public function newResultObject() {
return new PhabricatorProfileMenuItemConfiguration(); return new PhabricatorProfileMenuItemConfiguration();
} }
@ -54,6 +60,13 @@ final class PhabricatorProfileMenuItemConfigurationQuery
$this->profilePHIDs); $this->profilePHIDs);
} }
if ($this->customPHIDs !== null) {
$where[] = qsprintf(
$conn,
'customPHID IN (%Ls)',
$this->customPHIDs);
}
return $where; return $where;
} }

View file

@ -12,6 +12,7 @@ final class PhabricatorProfileMenuItemConfiguration
protected $builtinKey; protected $builtinKey;
protected $menuItemOrder; protected $menuItemOrder;
protected $visibility; protected $visibility;
protected $customPHID;
protected $menuItemProperties = array(); protected $menuItemProperties = array();
private $profileObject = self::ATTACHABLE; private $profileObject = self::ATTACHABLE;
@ -52,6 +53,7 @@ final class PhabricatorProfileMenuItemConfiguration
'menuItemKey' => 'text64', 'menuItemKey' => 'text64',
'builtinKey' => 'text64?', 'builtinKey' => 'text64?',
'menuItemOrder' => 'uint32?', 'menuItemOrder' => 'uint32?',
'customPHID' => 'phid?',
'visibility' => 'text32', 'visibility' => 'text32',
), ),
self::CONFIG_KEY_SCHEMA => array( self::CONFIG_KEY_SCHEMA => array(