Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/item/NuanceItemType.php
| Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | abstract class NuanceItemType | ||||
| protected function handleAction(NuanceItem $item, $action) { | protected function handleAction(NuanceItem $item, $action) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| final public function buildWorkCommands(NuanceItem $item) { | final public function buildWorkCommands(NuanceItem $item) { | ||||
| return $this->newWorkCommands($item); | return $this->newWorkCommands($item); | ||||
| } | } | ||||
| final public function applyCommand( | |||||
| NuanceItem $item, | |||||
| NuanceItemCommand $command) { | |||||
| $result = $this->handleCommand($item, $command); | |||||
| if ($result === null) { | |||||
| return; | |||||
| } | |||||
| $xaction = id(new NuanceItemTransaction()) | |||||
| ->setTransactionType(NuanceItemCommandTransaction::TRANSACTIONTYPE) | |||||
| ->setNewValue( | |||||
| array( | |||||
| 'command' => $command->getCommand(), | |||||
| 'parameters' => $command->getParameters(), | |||||
| 'result' => $result, | |||||
| )); | |||||
| $viewer = $this->getViewer(); | |||||
| // TODO: Maybe preserve the actor's original content source? | |||||
| $source = PhabricatorContentSource::newForSource( | |||||
| PhabricatorDaemonContentSource::SOURCECONST); | |||||
| $editor = id(new NuanceItemEditor()) | |||||
| ->setActor($viewer) | |||||
| ->setActingAsPHID($command->getAuthorPHID()) | |||||
| ->setContentSource($source) | |||||
| ->setContinueOnMissingFields(true) | |||||
| ->setContinueOnNoEffect(true) | |||||
| ->applyTransactions($item, array($xaction)); | |||||
| } | |||||
| protected function handleCommand( | |||||
| NuanceItem $item, | |||||
| NuanceItemCommand $command) { | |||||
| return null; | |||||
| } | |||||
| final protected function newContentSource( | final protected function newContentSource( | ||||
| NuanceItem $item, | NuanceItem $item, | ||||
| $agent_phid) { | $agent_phid) { | ||||
| return PhabricatorContentSource::newForSource( | return PhabricatorContentSource::newForSource( | ||||
| NuanceContentSource::SOURCECONST, | NuanceContentSource::SOURCECONST, | ||||
| array( | array( | ||||
| 'itemPHID' => $item->getPHID(), | 'itemPHID' => $item->getPHID(), | ||||
| 'agentPHID' => $agent_phid, | 'agentPHID' => $agent_phid, | ||||
| Show All 12 Lines | |||||