Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistCloseWorkflow.php
| Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | if (!isset($status_options[$status])) { | ||||
| $options = array_keys($status_options); | $options = array_keys($status_options); | ||||
| $last = array_pop($options); | $last = array_pop($options); | ||||
| echo "Invalid status {$status}, valid options are ". | echo "Invalid status {$status}, valid options are ". | ||||
| implode(', ', $options).", or {$last}.\n"; | implode(', ', $options).", or {$last}.\n"; | ||||
| return; | return; | ||||
| } | } | ||||
| foreach ($ids as $id) { | foreach ($ids as $id) { | ||||
| if (!preg_match("/^T?\d+$/", $id)) { | if (!preg_match('/^T?\d+$/', $id)) { | ||||
| echo "Invalid Task ID: {$id}.\n"; | echo "Invalid Task ID: {$id}.\n"; | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| $id = ltrim($id, 'T'); | $id = ltrim($id, 'T'); | ||||
| $result = $this->closeTask($id, $status, $message); | $result = $this->closeTask($id, $status, $message); | ||||
| $current_status = $status_options[$status]; | $current_status = $status_options[$status]; | ||||
| if ($result) { | if ($result) { | ||||
| echo "T{$id}'s status is now set to {$current_status}.\n"; | echo "T{$id}'s status is now set to {$current_status}.\n"; | ||||
| } else { | } else { | ||||
| echo "T{$id} is already set to {$current_status}.\n"; | echo "T{$id} is already set to {$current_status}.\n"; | ||||
| } | } | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| private function closeTask($task_id, $status, $comment = "") { | private function closeTask($task_id, $status, $comment = '') { | ||||
| $conduit = $this->getConduit(); | $conduit = $this->getConduit(); | ||||
| $info = $conduit->callMethodSynchronous( | $info = $conduit->callMethodSynchronous( | ||||
| 'maniphest.info', | 'maniphest.info', | ||||
| array( | array( | ||||
| 'task_id' => $task_id | 'task_id' => $task_id | ||||
| )); | )); | ||||
| if ($info['status'] == $status) { | if ($info['status'] == $status) { | ||||
| return false; | return false; | ||||
| Show All 11 Lines | |||||