Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15415178
D17149.id41241.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D17149.id41241.diff
View Options
diff --git a/resources/sql/autopatches/20170106.menu.01.customphd.sql b/resources/sql/autopatches/20170106.menu.01.customphd.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20170106.menu.01.customphd.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_search.search_profilepanelconfiguration
+ ADD customPHID VARBINARY(64);
diff --git a/src/applications/search/editor/PhabricatorProfileMenuEditEngine.php b/src/applications/search/editor/PhabricatorProfileMenuEditEngine.php
--- a/src/applications/search/editor/PhabricatorProfileMenuEditEngine.php
+++ b/src/applications/search/editor/PhabricatorProfileMenuEditEngine.php
@@ -7,6 +7,7 @@
private $menuEngine;
private $profileObject;
+ private $customObject;
private $newMenuItemConfiguration;
private $isBuiltin;
@@ -32,6 +33,15 @@
return $this->profileObject;
}
+ public function setCustomObject($custom_object) {
+ $this->customObject = $custom_object;
+ return $this;
+ }
+
+ public function getCustomObject() {
+ return $this->customObject;
+ }
+
public function setNewMenuItemConfiguration(
PhabricatorProfileMenuItemConfiguration $configuration) {
$this->newMenuItemConfiguration = $configuration;
diff --git a/src/applications/search/engine/PhabricatorProfileMenuEngine.php b/src/applications/search/engine/PhabricatorProfileMenuEngine.php
--- a/src/applications/search/engine/PhabricatorProfileMenuEngine.php
+++ b/src/applications/search/engine/PhabricatorProfileMenuEngine.php
@@ -4,6 +4,7 @@
private $viewer;
private $profileObject;
+ private $customObject;
private $items;
private $defaultItem;
private $controller;
@@ -27,6 +28,15 @@
return $this->profileObject;
}
+ public function setCustomObject($custom_object) {
+ $this->customObject = $custom_object;
+ return $this;
+ }
+
+ public function getCustomObject() {
+ return $this->customObject;
+ }
+
public function setController(PhabricatorController $controller) {
$this->controller = $controller;
return $this;
@@ -241,12 +251,18 @@
private function loadItems() {
$viewer = $this->getViewer();
$object = $this->getProfileObject();
+ $custom = $this->getCustomObject();
+ $custom_phid = null;
+ if ($custom) {
+ $custom_phid = $custom->getPHID();
+ }
$items = $this->loadBuiltinProfileItems();
$stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery())
->setViewer($viewer)
->withProfilePHIDs(array($object->getPHID()))
+ ->withCustomPHIDs(array($custom_phid))
->execute();
foreach ($stored_items as $stored_item) {
diff --git a/src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php b/src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php
--- a/src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php
+++ b/src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php
@@ -6,6 +6,7 @@
private $ids;
private $phids;
private $profilePHIDs;
+ private $customPHIDs;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -22,6 +23,11 @@
return $this;
}
+ public function withCustomPHIDs(array $phids) {
+ $this->customPHIDs = $phids;
+ return $this;
+ }
+
public function newResultObject() {
return new PhabricatorProfileMenuItemConfiguration();
}
@@ -54,6 +60,13 @@
$this->profilePHIDs);
}
+ if ($this->customPHIDs !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'customPHID IN (%Ls)',
+ $this->customPHIDs);
+ }
+
return $where;
}
@@ -93,6 +106,26 @@
$item->attachProfileObject($profile);
}
+ /* Might not be needed? */
+ $custom_phids = mpull($page, 'getCustomPHID');
+
+ $profiles = id(new PhabricatorObjectQuery())
+ ->setViewer($this->getViewer())
+ ->setParentQuery($this)
+ ->withPHIDs($custom_phids)
+ ->execute();
+ $profiles = mpull($profiles, null, 'getPHID');
+
+ foreach ($page as $key => $item) {
+ $profile = idx($profiles, $item->getCustomPHID());
+ if (!$profile) {
+ $this->didRejectResult($item);
+ unset($page[$key]);
+ continue;
+ }
+ $item->attachCustomObject($profile);
+ }
+
return $page;
}
diff --git a/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php b/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php
--- a/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php
+++ b/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php
@@ -12,9 +12,11 @@
protected $builtinKey;
protected $menuItemOrder;
protected $visibility;
+ protected $customPHID;
protected $menuItemProperties = array();
private $profileObject = self::ATTACHABLE;
+ private $customObject = self::ATTACHABLE;
private $menuItem = self::ATTACHABLE;
const VISIBILITY_DEFAULT = 'default';
@@ -52,6 +54,7 @@
'menuItemKey' => 'text64',
'builtinKey' => 'text64?',
'menuItemOrder' => 'uint32?',
+ 'customPHID' => 'phid?',
'visibility' => 'text32',
),
self::CONFIG_KEY_SCHEMA => array(
@@ -85,6 +88,15 @@
return $this->assertAttached($this->profileObject);
}
+ public function attachCustomObject($custom_object) {
+ $this->customObject = $custom_object;
+ return $this;
+ }
+
+ public function getCustomObject() {
+ return $this->assertAttached($this->customObject);
+ }
+
public function setMenuItemProperty($key, $value) {
$this->menuItemProperties[$key] = $value;
return $this;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 21, 4:37 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7714976
Default Alt Text
D17149.id41241.diff (5 KB)
Attached To
Mode
D17149: Add CustomPHID to PhabricatorProfileMenuEngineConfiguration
Attached
Detach File
Event Timeline
Log In to Comment