From 3b226e8fb330d4175d9349ed41addbc381d91a01 Mon Sep 17 00:00:00 2001 From: lkassianik Date: Mon, 27 Apr 2015 15:31:18 -0700 Subject: [PATCH] Calendar event monograms, part 4. Typing E{id} makes the object available in global search. Summary: Closes T7928, E{id} is available via global search. Test Plan: Create calendar event, search for its monogram in global search, event should be accessible. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7928 Differential Revision: https://secure.phabricator.com/D12581 --- .../phid/PhabricatorCalendarEventPHIDType.php | 28 +++++++++++++++++++ .../phid/DifferentialRevisionPHIDType.php | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/applications/calendar/phid/PhabricatorCalendarEventPHIDType.php b/src/applications/calendar/phid/PhabricatorCalendarEventPHIDType.php index 68ae85cf65..fc6370c8fd 100644 --- a/src/applications/calendar/phid/PhabricatorCalendarEventPHIDType.php +++ b/src/applications/calendar/phid/PhabricatorCalendarEventPHIDType.php @@ -38,4 +38,32 @@ final class PhabricatorCalendarEventPHIDType extends PhabricatorPHIDType { } } + public function canLoadNamedObject($name) { + return preg_match('/^E[1-9]\d*$/i', $name); + } + + public function loadNamedObjects( + PhabricatorObjectQuery $query, + array $names) { + + $id_map = array(); + foreach ($names as $name) { + $id = (int)substr($name, 1); + $id_map[$id][] = $name; + } + + $objects = id(new PhabricatorCalendarEventQuery()) + ->setViewer($query->getViewer()) + ->withIDs(array_keys($id_map)) + ->execute(); + + $results = array(); + foreach ($objects as $id => $object) { + foreach (idx($id_map, $id, array()) as $name) { + $results[$name] = $object; + } + } + + return $results; + } } diff --git a/src/applications/differential/phid/DifferentialRevisionPHIDType.php b/src/applications/differential/phid/DifferentialRevisionPHIDType.php index dbf473fe98..d65d2d601c 100644 --- a/src/applications/differential/phid/DifferentialRevisionPHIDType.php +++ b/src/applications/differential/phid/DifferentialRevisionPHIDType.php @@ -47,7 +47,7 @@ final class DifferentialRevisionPHIDType extends PhabricatorPHIDType { } public function canLoadNamedObject($name) { - return preg_match('/^D\d*[1-9]\d*$/i', $name); + return preg_match('/^D[1-9]\d*$/i', $name); } public function loadNamedObjects(