Ejemplo n.º 1
0
 /**
  * Prints a string to STDOUT.
  *
  * You may optionally format the string with ANSI codes by
  * passing additional parameters using the constants defined in [[\Eddmash\PowerOrm\ConsoleConsole]].
  *
  * Example:
  *
  * ```
  * $this->stdout('This will be red and underlined.', Console::FG_RED, Console::UNDERLINE);
  * ```
  *
  * @param string $string the string to print
  *
  * @return int|bool Number of bytes printed or false on error
  */
 public function stdout($string)
 {
     if ($this->isColorEnabled()) {
         $args = func_get_args();
         array_shift($args);
         $string = Console::ansiFormat($string, $args);
     }
     return Console::stdout($string);
 }
Ejemplo n.º 2
0
 /**
  * Applies the migration to the database.
  *
  * @param ProjectState $state     this is the state before the migration is applied
  * @param Migration    $migration the migration to apply
  * @param bool         $fake
  *
  * @return mixed
  *
  * @since 1.1.0
  *
  * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**>
  */
 public function applyMigration($state, $migration, $fake = false)
 {
     Console::stdout(sprintf(' Applying %s...', $migration->getName()));
     if (!$fake) {
         $state = $migration->apply($state, $this->schemaEditor);
     }
     $this->recorder->recordApplied(['name' => $migration->getName()]);
     if ($fake) {
         $end = Console::ansiFormat('FAKED', [Console::FG_GREEN]);
     } else {
         $end = Console::ansiFormat('OK', [Console::FG_GREEN]);
     }
     Console::stdout($end . PHP_EOL);
     return $state;
 }