Commit 8a85ee7c authored by Chad Little's avatar Chad Little
Browse files

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
parent 363084d4
ALTER TABLE {$NAMESPACE}_search.search_profilepanelconfiguration
ADD customPHID VARBINARY(64);
......@@ -7,6 +7,7 @@ final class PhabricatorProfileMenuEditEngine
private $menuEngine;
private $profileObject;
private $customPHID;
private $newMenuItemConfiguration;
private $isBuiltin;
......@@ -32,6 +33,15 @@ final class PhabricatorProfileMenuEditEngine
return $this->profileObject;
}
public function setCustomPHID($custom_phid) {
$this->customPHID = $custom_phid;
return $this;
}
public function getCustomPHID() {
return $this->customPHID;
}
public function setNewMenuItemConfiguration(
PhabricatorProfileMenuItemConfiguration $configuration) {
$this->newMenuItemConfiguration = $configuration;
......
......@@ -4,6 +4,7 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
private $viewer;
private $profileObject;
private $customPHID;
private $items;
private $defaultItem;
private $controller;
......@@ -27,6 +28,15 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
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) {
$this->controller = $controller;
return $this;
......@@ -244,10 +254,18 @@ abstract class PhabricatorProfileMenuEngine extends Phobject {
$items = $this->loadBuiltinProfileItems();
$stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery())
->setViewer($viewer)
->withProfilePHIDs(array($object->getPHID()))
->execute();
if ($this->getCustomPHID()) {
$stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery())
->setViewer($viewer)
->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) {
$impl = $stored_item->getMenuItem();
......
......@@ -6,6 +6,7 @@ final class PhabricatorProfileMenuItemConfigurationQuery
private $ids;
private $phids;
private $profilePHIDs;
private $customPHIDs;
public function withIDs(array $ids) {
$this->ids = $ids;
......@@ -22,6 +23,11 @@ final class PhabricatorProfileMenuItemConfigurationQuery
return $this;
}
public function withCustomPHIDs(array $phids) {
$this->customPHIDs = $phids;
return $this;
}
public function newResultObject() {
return new PhabricatorProfileMenuItemConfiguration();
}
......@@ -54,6 +60,13 @@ final class PhabricatorProfileMenuItemConfigurationQuery
$this->profilePHIDs);
}
if ($this->customPHIDs !== null) {
$where[] = qsprintf(
$conn,
'customPHID IN (%Ls)',
$this->customPHIDs);
}
return $where;
}
......
......@@ -12,6 +12,7 @@ final class PhabricatorProfileMenuItemConfiguration
protected $builtinKey;
protected $menuItemOrder;
protected $visibility;
protected $customPHID;
protected $menuItemProperties = array();
private $profileObject = self::ATTACHABLE;
......@@ -52,6 +53,7 @@ final class PhabricatorProfileMenuItemConfiguration
'menuItemKey' => 'text64',
'builtinKey' => 'text64?',
'menuItemOrder' => 'uint32?',
'customPHID' => 'phid?',
'visibility' => 'text32',
),
self::CONFIG_KEY_SCHEMA => array(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment