/** * Ths method performs the execution of all active flows. * * @param string $spacer Prefix to add on each log line promptted on * terminal. */ protected function taskRun($spacer = "") { echo "{$spacer}Running workflows:\n"; // // Shortcuts. $manager = \TooBasic\Workflows\WorkflowManager::Instance(); // // Loading filters. $workflowName = isset($this->params->opt->{self::OptionWorkflow}) ? $this->params->opt->{self::OptionWorkflow} : false; // // Loading known workflow names. $knownWorkflows = $manager->knownWorkflows(); // // Waking up workflows. echo "{$spacer}\tWaking up items:\n"; foreach ($knownWorkflows as $name) { // // Filtering. if ($workflowName && $workflowName != $name) { continue; } // // Shaking the bed :) echo "{$spacer}\t\t- '{$name}': "; $manager->wakeUpItems($name); echo Color::Green("Done\n"); } // // Running workflows. echo "{$spacer}\tRunning workflows:\n"; foreach ($knownWorkflows as $name) { // // Filtering. if ($workflowName && $workflowName != $name) { continue; } // // Retrieving active flow for certain workflow. echo "{$spacer}\t\tObtaining active flows for '{$name}': "; $flows = $manager->activeFlows(false, false, $name); $countFlows = count($flows); echo Color::Green("{$countFlows}\n"); // // Running active flows. if ($countFlows) { echo "{$spacer}\t\tRunning flows for '{$name}':\n"; foreach ($flows as $flow) { echo "{$spacer}\t\t\tRunning item '{$flow->type}:{$flow->item}' on workflow '{$flow->workflow}': "; if ($manager->run($flow)) { echo Color::Green("Done\n"); } else { echo Color::Red("Failed\n"); } } } } }
/** * Ths method inserts a new flow in the system. * * @param string $spacer Prefix to add on each log line promptted on * terminal. */ protected function taskInject($spacer = "") { // // Checking required parameters. if (!$this->params->opt->{self::OptionType}) { $this->setError(self::ErrorWrongParameters, 'No type specified'); } elseif (!$this->params->opt->{self::OptionId}) { $this->setError(self::ErrorWrongParameters, 'No ID specified'); } elseif (!$this->params->opt->{self::OptionWorkflow}) { $this->setError(self::ErrorWrongParameters, 'No workflow specified'); } else { // // Shortcuts. $type = $this->params->opt->{self::OptionType}; $id = $this->params->opt->{self::OptionId}; $workflow = $this->params->opt->{self::OptionWorkflow}; // // Loading manager. $manager = \TooBasic\Workflows\WorkflowManager::Instance(); // // Injecting... echo "{$spacer}Injecting item '{$type}:{$id}' for workflow '{$workflow}': "; $error = false; if ($manager->injectDirect($type, $id, $workflow, $error)) { echo Color::Green("Done\n"); } else { echo Color::Red("Failed") . " (Error " . Color::Yellow($error) . ")\n"; } } }
protected function taskUpdateCounts($spacer = "") { echo "{$spacer}Updating tag counts: "; $this->model->tags_manager('Tagger')->updateCounts(); echo Color::Green("Done\n"); }