Differential D7326 Diff 23778 src/applications/phrequent/conduit/ConduitAPI_phrequent_pop_Method.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phrequent/conduit/ConduitAPI_phrequent_pop_Method.php
- This file was added.
<?php | |||||
final class ConduitAPI_phrequent_pop_Method | |||||
extends ConduitAPI_phrequent_Method { | |||||
public function getMethodDescription() { | |||||
return pht('Stop tracking time on an object by popping it from the stack.'); | |||||
} | |||||
public function getMethodStatus() { | |||||
return self::METHOD_STATUS_UNSTABLE; | |||||
epriestley: pht() this | |||||
} | |||||
public function defineParamTypes() { | |||||
return array( | |||||
'objectPHID' => 'phid', | |||||
'stopTime' => 'int', | |||||
'note' => 'string' | |||||
); | |||||
} | |||||
Not Done Inline ActionsName this objectPHID to make the type more explicit/clear. (This is also more conventional.) epriestley: Name this `objectPHID` to make the type more explicit/clear. (This is also more conventional.) | |||||
Not Done Inline ActionsI think this should be optional. If not present, whatever's on top of the stack is popped. We can do this in the future, though. epriestley: I think this should be optional. If not present, whatever's on top of the stack is popped. We… | |||||
public function defineReturnType() { | |||||
return 'phid'; | |||||
Not Done Inline ActionsIn the future, it might be reasonable to let you adjust the start time from this call too. Maybe call timestamp something like endTime to allow for this and make usage more clear? epriestley: In the future, it might be reasonable to let you adjust the start time from this call too. | |||||
} | |||||
public function defineErrorTypes() { | |||||
return array( | |||||
); | |||||
} | |||||
protected function execute(ConduitAPIRequest $request) { | |||||
$user = $request->getUser(); | |||||
$object_phid = $request->getValue('objectPHID'); | |||||
$timestamp = $request->getValue('stopTime'); | |||||
$note = $request->getValue('note'); | |||||
Not Done Inline ActionsCall this $object_phid -- many objects have both (global) PHIDs and (local) IDs. epriestley: Call this `$object_phid` -- many objects have both (global) PHIDs and (local) IDs. | |||||
if ($timestamp === null) { | |||||
$timestamp = time(); | |||||
} | |||||
$editor = new PhrequentTrackingEditor(); | |||||
Not Done Inline ActionsI think this should return the popped object, if one was popped. We can do that in the future, though. epriestley: I think this should return the popped object, if one was popped. We can do that in the future… | |||||
if (!$object_phid) { | |||||
return $editor->stopTrackingTop($user, $timestamp, $note); | |||||
} else { | |||||
return $editor->stopTracking($user, $object_phid, $timestamp, $note); | |||||
} | |||||
} | |||||
} |
pht() this