/** * Migrates the database down to the version specified if no version is given it migrates to version 0 * @param string $to_version */ public static function down($to_version = 0) { $current = static::current_version(); $table = static::migration_table_name(); $data = static::load_files(static::$dir); $data = array_reverse($data, true); foreach ($data as $version => $class) { if ((int) $version < (int) $to_version) { continue; } if ((int) $current < (int) $version) { continue; } print CommandLineColor::underline('Running') . " " . CommandLineColor::underline_blue($class) . " - " . CommandLineColor::yellow($version) . "\n"; $klass = new $class(); $klass->down(); static::delete_version($version); } }
public static function echo_path($type, $path) { if (defined("NIMBLE_IS_TESTING")) { return; } echo CommandLineColor::blue($type) . ': ' . CommandLineColor::yellow($path) . "\n"; }
/** * Dump out application routes to a human readable format. * @param boolean $cli True if being called from the command line. * @return string The application's routes in a human readable format. */ public static function dumpRoutes($cli = false) { $klass = Nimble::getInstance(); $out = array(); foreach ($klass->routes as $route) { $pattern = self::clean_route($route->rule); $pattern = empty($pattern) ? 'root path' : $pattern; $string = ''; if (!empty($route->short_url)) { $string .= ' ' . CommandLineColor::underline('Short Url:') . ' ' . CommandLineColor::yellow($route->short_url) . ' '; } $string .= CommandLineColor::underline("Controller:") . ' ' . CommandLineColor::yellow($route->controller) . ' ' . CommandLineColor::underline('Action:') . ' ' . CommandLineColor::magenta($route->method) . ' ' . CommandLineColor::underline('Method:') . ' ' . CommandLineColor::green($route->http_method) . ' ' . CommandLineColor::underline('Pattern:') . ' ' . CommandLineColor::bold_red($pattern); array_push($out, $string); } $return = "\n"; $return .= join("\n", $out); $return .= "\n"; return $cli ? $return : htmlspecialchars($return); }