Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/worker/NuanceItemUpdateWorker.php
| Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | $commands = id(new NuanceItemCommandQuery()) | ||||
| ->withItemPHIDs(array($item->getPHID())) | ->withItemPHIDs(array($item->getPHID())) | ||||
| ->withStatuses( | ->withStatuses( | ||||
| array( | array( | ||||
| NuanceItemCommand::STATUS_ISSUED, | NuanceItemCommand::STATUS_ISSUED, | ||||
| )) | )) | ||||
| ->execute(); | ->execute(); | ||||
| $commands = msort($commands, 'getID'); | $commands = msort($commands, 'getID'); | ||||
| $executors = NuanceCommandImplementation::getAllCommands(); | |||||
| foreach ($commands as $command) { | foreach ($commands as $command) { | ||||
| $command | $command | ||||
| ->setStatus(NuanceItemCommand::STATUS_EXECUTING) | ->setStatus(NuanceItemCommand::STATUS_EXECUTING) | ||||
| ->save(); | ->save(); | ||||
| try { | try { | ||||
| $impl->applyCommand($item, $command); | $command_key = $command->getCommand(); | ||||
| $executor = idx($executors, $command_key); | |||||
| if (!$executor) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Unable to execute command "%s": this command does not have '. | |||||
| 'a recognized command implementation.', | |||||
| $command_key)); | |||||
| } | |||||
| $executor = clone $executor; | |||||
| $executor | |||||
| ->setActor($viewer) | |||||
| ->applyCommand($item, $command); | |||||
| $command | $command | ||||
| ->setStatus(NuanceItemCommand::STATUS_DONE) | ->setStatus(NuanceItemCommand::STATUS_DONE) | ||||
| ->save(); | ->save(); | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| $command | $command | ||||
| ->setStatus(NuanceItemCommand::STATUS_FAILED) | ->setStatus(NuanceItemCommand::STATUS_FAILED) | ||||
| ->save(); | ->save(); | ||||
| throw $ex; | throw $ex; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||