Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/worker/NuanceItemUpdateWorker.php
| Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | private function applyCommands(NuanceItem $item) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $impl = $item->getImplementation(); | $impl = $item->getImplementation(); | ||||
| $impl->setViewer($viewer); | $impl->setViewer($viewer); | ||||
| $commands = id(new NuanceItemCommandQuery()) | $commands = id(new NuanceItemCommandQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withItemPHIDs(array($item->getPHID())) | ->withItemPHIDs(array($item->getPHID())) | ||||
| ->withStatuses( | |||||
| array( | |||||
| NuanceItemCommand::STATUS_ISSUED, | |||||
| )) | |||||
| ->execute(); | ->execute(); | ||||
| $commands = msort($commands, 'getID'); | $commands = msort($commands, 'getID'); | ||||
| foreach ($commands as $command) { | foreach ($commands as $command) { | ||||
| $command | |||||
| ->setStatus(NuanceItemCommand::STATUS_EXECUTING) | |||||
| ->save(); | |||||
| try { | |||||
| $impl->applyCommand($item, $command); | $impl->applyCommand($item, $command); | ||||
| $command->delete(); | |||||
| $command | |||||
| ->setStatus(NuanceItemCommand::STATUS_DONE) | |||||
| ->save(); | |||||
| } catch (Exception $ex) { | |||||
| $command | |||||
| ->setStatus(NuanceItemCommand::STATUS_FAILED) | |||||
| ->save(); | |||||
| throw $ex; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||