/** * Dispatch * * @param DbSync_Console $console * @return mixed */ public function dispatch(DbSync_Console $console) { $this->_console = $console; $items = $console->getArguments(); $action = $this->getActionMethod(array_shift($items)); if ('helpAction' == $action) { return $this->helpAction(); } if (!$items) { $items = $this->getItemsList($action); } if (!$items) { echo $this->colorize("Nothing to sync", 'red'); return; } $updated = true; $stop = false; while ($items && !$stop) { $stop = !$updated; $updated = false; foreach ($items as $i => $name) { try { $this->_run($action, $name); unset($items[$i]); $updated = true; echo PHP_EOL; } catch (DbSync_Exception $e) { if ($stop) { echo $name . $this->colorize(" - " . $e->getMessage(), 'red'); echo PHP_EOL; } } } } }
/** * Get controllers * * @param DbSync_Console $console * @return array */ public function getControllers(DbSync_Console $console) { $controller = $console->getArgument(0); if (isset($this->_controllers[$controller])) { $controllers = $controller; //remove controller from arguments $args = $console->getArguments(); unset($args['0']); $console->setArguments($args); } else { $controllers = array_keys($this->_controllers); } return (array) $controllers; }