mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 13:52:40 +01:00
Use application PHIDs in countdown
Summary: Ref T2715. Swap countdown to application PHIDs. Test Plan: Used `phid.lookup`; `phid.query`. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2715 Differential Revision: https://secure.phabricator.com/D6532
This commit is contained in:
parent
3aa5fcfcc7
commit
f00b43d448
11 changed files with 90 additions and 30 deletions
|
@ -283,7 +283,6 @@ phutil_register_library_map(array(
|
||||||
'ConpherenceViewController' => 'applications/conpherence/controller/ConpherenceViewController.php',
|
'ConpherenceViewController' => 'applications/conpherence/controller/ConpherenceViewController.php',
|
||||||
'ConpherenceWidgetController' => 'applications/conpherence/controller/ConpherenceWidgetController.php',
|
'ConpherenceWidgetController' => 'applications/conpherence/controller/ConpherenceWidgetController.php',
|
||||||
'ConpherenceWidgetView' => 'applications/conpherence/view/ConpherenceWidgetView.php',
|
'ConpherenceWidgetView' => 'applications/conpherence/view/ConpherenceWidgetView.php',
|
||||||
'CountdownQuery' => 'applications/countdown/query/CountdownQuery.php',
|
|
||||||
'DarkConsoleController' => 'aphront/console/DarkConsoleController.php',
|
'DarkConsoleController' => 'aphront/console/DarkConsoleController.php',
|
||||||
'DarkConsoleCore' => 'aphront/console/DarkConsoleCore.php',
|
'DarkConsoleCore' => 'aphront/console/DarkConsoleCore.php',
|
||||||
'DarkConsoleDataController' => 'aphront/console/DarkConsoleDataController.php',
|
'DarkConsoleDataController' => 'aphront/console/DarkConsoleDataController.php',
|
||||||
|
@ -998,6 +997,8 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCountdownDeleteController' => 'applications/countdown/controller/PhabricatorCountdownDeleteController.php',
|
'PhabricatorCountdownDeleteController' => 'applications/countdown/controller/PhabricatorCountdownDeleteController.php',
|
||||||
'PhabricatorCountdownEditController' => 'applications/countdown/controller/PhabricatorCountdownEditController.php',
|
'PhabricatorCountdownEditController' => 'applications/countdown/controller/PhabricatorCountdownEditController.php',
|
||||||
'PhabricatorCountdownListController' => 'applications/countdown/controller/PhabricatorCountdownListController.php',
|
'PhabricatorCountdownListController' => 'applications/countdown/controller/PhabricatorCountdownListController.php',
|
||||||
|
'PhabricatorCountdownPHIDTypeCountdown' => 'applications/countdown/phid/PhabricatorCountdownPHIDTypeCountdown.php',
|
||||||
|
'PhabricatorCountdownQuery' => 'applications/countdown/query/PhabricatorCountdownQuery.php',
|
||||||
'PhabricatorCountdownRemarkupRule' => 'applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php',
|
'PhabricatorCountdownRemarkupRule' => 'applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php',
|
||||||
'PhabricatorCountdownViewController' => 'applications/countdown/controller/PhabricatorCountdownViewController.php',
|
'PhabricatorCountdownViewController' => 'applications/countdown/controller/PhabricatorCountdownViewController.php',
|
||||||
'PhabricatorCountedToggleButtonsExample' => 'applications/uiexample/examples/PhabricatorCountedToggleButtonsExample.php',
|
'PhabricatorCountedToggleButtonsExample' => 'applications/uiexample/examples/PhabricatorCountedToggleButtonsExample.php',
|
||||||
|
@ -2257,7 +2258,6 @@ phutil_register_library_map(array(
|
||||||
'ConpherenceViewController' => 'ConpherenceController',
|
'ConpherenceViewController' => 'ConpherenceController',
|
||||||
'ConpherenceWidgetController' => 'ConpherenceController',
|
'ConpherenceWidgetController' => 'ConpherenceController',
|
||||||
'ConpherenceWidgetView' => 'AphrontView',
|
'ConpherenceWidgetView' => 'AphrontView',
|
||||||
'CountdownQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
|
||||||
'DarkConsoleController' => 'PhabricatorController',
|
'DarkConsoleController' => 'PhabricatorController',
|
||||||
'DarkConsoleDataController' => 'PhabricatorController',
|
'DarkConsoleDataController' => 'PhabricatorController',
|
||||||
'DarkConsoleErrorLogPlugin' => 'DarkConsolePlugin',
|
'DarkConsoleErrorLogPlugin' => 'DarkConsolePlugin',
|
||||||
|
@ -2996,6 +2996,8 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCountdownDeleteController' => 'PhabricatorCountdownController',
|
'PhabricatorCountdownDeleteController' => 'PhabricatorCountdownController',
|
||||||
'PhabricatorCountdownEditController' => 'PhabricatorCountdownController',
|
'PhabricatorCountdownEditController' => 'PhabricatorCountdownController',
|
||||||
'PhabricatorCountdownListController' => 'PhabricatorCountdownController',
|
'PhabricatorCountdownListController' => 'PhabricatorCountdownController',
|
||||||
|
'PhabricatorCountdownPHIDTypeCountdown' => 'PhabricatorPHIDType',
|
||||||
|
'PhabricatorCountdownQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PhabricatorCountdownRemarkupRule' => 'PhabricatorRemarkupRuleObject',
|
'PhabricatorCountdownRemarkupRule' => 'PhabricatorRemarkupRuleObject',
|
||||||
'PhabricatorCountdownViewController' => 'PhabricatorCountdownController',
|
'PhabricatorCountdownViewController' => 'PhabricatorCountdownController',
|
||||||
'PhabricatorCountedToggleButtonsExample' => 'PhabricatorUIExample',
|
'PhabricatorCountedToggleButtonsExample' => 'PhabricatorUIExample',
|
||||||
|
|
|
@ -17,7 +17,7 @@ final class PhabricatorCountdownDeleteController
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
|
||||||
$countdown = id(new CountdownQuery())
|
$countdown = id(new PhabricatorCountdownQuery())
|
||||||
->setViewer($user)
|
->setViewer($user)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($this->id))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
|
@ -18,7 +18,7 @@ final class PhabricatorCountdownEditController
|
||||||
$action_label = pht('Create Countdown');
|
$action_label = pht('Create Countdown');
|
||||||
|
|
||||||
if ($this->id) {
|
if ($this->id) {
|
||||||
$countdown = id(new CountdownQuery())
|
$countdown = id(new PhabricatorCountdownQuery())
|
||||||
->setViewer($user)
|
->setViewer($user)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($this->id))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
|
@ -14,7 +14,7 @@ final class PhabricatorCountdownListController
|
||||||
$pager = new AphrontCursorPagerView();
|
$pager = new AphrontCursorPagerView();
|
||||||
$pager->readFromRequest($request);
|
$pager->readFromRequest($request);
|
||||||
|
|
||||||
$query = id(new CountdownQuery())
|
$query = id(new PhabricatorCountdownQuery())
|
||||||
->setViewer($user);
|
->setViewer($user);
|
||||||
|
|
||||||
$countdowns = $query->executeWithCursorPager($pager);
|
$countdowns = $query->executeWithCursorPager($pager);
|
||||||
|
|
|
@ -18,7 +18,7 @@ final class PhabricatorCountdownViewController
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
|
||||||
$countdown = id(new CountdownQuery())
|
$countdown = id(new PhabricatorCountdownQuery())
|
||||||
->setViewer($user)
|
->setViewer($user)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($this->id))
|
||||||
->executeOne();
|
->executeOne();
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorCountdownPHIDTypeCountdown extends PhabricatorPHIDType {
|
||||||
|
|
||||||
|
const TYPECONST = 'CDWN';
|
||||||
|
|
||||||
|
public function getTypeConstant() {
|
||||||
|
return self::TYPECONST;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTypeName() {
|
||||||
|
return pht('Countdown');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newObject() {
|
||||||
|
return new PhabricatorCountdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadObjects(
|
||||||
|
PhabricatorObjectQuery $query,
|
||||||
|
array $phids) {
|
||||||
|
|
||||||
|
return id(new PhabricatorCountdownQuery())
|
||||||
|
->setViewer($query->getViewer())
|
||||||
|
->withPHIDs($phids)
|
||||||
|
->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadHandles(
|
||||||
|
PhabricatorHandleQuery $query,
|
||||||
|
array $handles,
|
||||||
|
array $objects) {
|
||||||
|
|
||||||
|
foreach ($handles as $phid => $handle) {
|
||||||
|
$countdown = $objects[$phid];
|
||||||
|
|
||||||
|
$name = $countdown->getTitle();
|
||||||
|
$id = $countdown->getID();
|
||||||
|
|
||||||
|
$handle->setName("C{$id}");
|
||||||
|
$handle->setFullName("C{$id}: {$name}");
|
||||||
|
$handle->setURI("/countdown/{$id}/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canLoadNamedObject($name) {
|
||||||
|
return preg_match('/^C\d*[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 PhabricatorCountdownQuery())
|
||||||
|
->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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
/**
|
/**
|
||||||
* @group countdown
|
* @group countdown
|
||||||
*/
|
*/
|
||||||
final class CountdownQuery
|
final class PhabricatorCountdownQuery
|
||||||
extends PhabricatorCursorPagedPolicyAwareQuery {
|
extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
|
|
||||||
private $ids;
|
private $ids;
|
|
@ -12,7 +12,7 @@ final class PhabricatorCountdownRemarkupRule
|
||||||
|
|
||||||
protected function loadObjects(array $ids) {
|
protected function loadObjects(array $ids) {
|
||||||
$viewer = $this->getEngine()->getConfig('viewer');
|
$viewer = $this->getEngine()->getConfig('viewer');
|
||||||
return id(new CountdownQuery())
|
return id(new PhabricatorCountdownQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withIDs($ids)
|
->withIDs($ids)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* @group countdown
|
* @group countdown
|
||||||
*/
|
*/
|
||||||
final class PhabricatorCountdown extends PhabricatorCountdownDAO
|
final class PhabricatorCountdown
|
||||||
|
extends PhabricatorCountdownDAO
|
||||||
implements PhabricatorPolicyInterface {
|
implements PhabricatorPolicyInterface {
|
||||||
|
|
||||||
protected $id;
|
protected $id;
|
||||||
|
@ -20,11 +21,12 @@ final class PhabricatorCountdown extends PhabricatorCountdownDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generatePHID() {
|
public function generatePHID() {
|
||||||
return PhabricatorPHID::generateNewPHID('CDWN');
|
return PhabricatorPHID::generateNewPHID(
|
||||||
|
PhabricatorCountdownPHIDTypeCountdown::TYPECONST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getViewPolicy() {
|
public function getViewPolicy() {
|
||||||
return "users";
|
return PhabricatorPolicies::POLICY_USER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -( PhabricatorPolicyInterface Implementation )------------------------- */
|
/* -( PhabricatorPolicyInterface Implementation )------------------------- */
|
||||||
|
|
|
@ -30,7 +30,6 @@ final class PhabricatorPHIDConstants {
|
||||||
const PHID_TYPE_PAYM = 'PAYM';
|
const PHID_TYPE_PAYM = 'PAYM';
|
||||||
const PHID_TYPE_CHRG = 'CHRG';
|
const PHID_TYPE_CHRG = 'CHRG';
|
||||||
const PHID_TYPE_CART = 'CART';
|
const PHID_TYPE_CART = 'CART';
|
||||||
const PHID_TYPE_CDWN = 'CDWN';
|
|
||||||
const PHID_TYPE_LEGD = 'LEGD';
|
const PHID_TYPE_LEGD = 'LEGD';
|
||||||
const PHID_TYPE_LEGB = 'LEGB';
|
const PHID_TYPE_LEGB = 'LEGB';
|
||||||
|
|
||||||
|
|
|
@ -492,24 +492,6 @@ final class PhabricatorObjectHandleData {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PhabricatorPHIDConstants::PHID_TYPE_CDWN:
|
|
||||||
foreach ($phids as $phid) {
|
|
||||||
$handle = new PhabricatorObjectHandle();
|
|
||||||
$handle->setPHID($phid);
|
|
||||||
$handle->setType($type);
|
|
||||||
if (empty($objects[$phid])) {
|
|
||||||
$handle->setName('Unknown Countdown');
|
|
||||||
} else {
|
|
||||||
$countdown = $objects[$phid];
|
|
||||||
$handle->setName($countdown->getTitle());
|
|
||||||
$handle->setFullName($countdown->getTitle());
|
|
||||||
$handle->setURI('/countdown/'.$countdown->getID().'/');
|
|
||||||
$handle->setComplete(true);
|
|
||||||
}
|
|
||||||
$handles[$phid] = $handle;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PhabricatorPHIDConstants::PHID_TYPE_LEGD:
|
case PhabricatorPHIDConstants::PHID_TYPE_LEGD:
|
||||||
foreach ($phids as $phid) {
|
foreach ($phids as $phid) {
|
||||||
$handle = new PhabricatorObjectHandle();
|
$handle = new PhabricatorObjectHandle();
|
||||||
|
|
Loading…
Reference in a new issue