コード例 #1
0
 /**
  * Report migration run info
  *
  * @museDescription  Shows a history of previously run migrations
  *
  * @return  void
  **/
 public function history()
 {
     $migration = new \Hubzero\Content\Migration();
     $history = $migration->history();
     $output = array();
     $maxFile = 0;
     $maxUser = 0;
     $maxScope = 0;
     if ($history && count($history) > 0) {
         foreach ($history as $entry) {
             if (strlen($entry->file) > $maxFile) {
                 $maxFile = strlen($entry->file);
             }
             if (strlen($entry->action_by) > $maxUser) {
                 $maxUser = strlen($entry->action_by);
             }
             if (strlen($entry->scope) > $maxScope) {
                 $maxScope = strlen($entry->scope);
             }
         }
         $width = $maxScope + $maxFile + $maxUser + 35;
         $this->output->addLine(' ' . str_repeat('-', $width));
         foreach ($history as $entry) {
             $padding1 = $maxFile - strlen($entry->file);
             $padding2 = $maxUser - strlen($entry->action_by);
             $this->output->addString('| ' . $entry->scope . DS . $entry->file . ' ' . str_repeat(' ', $padding1));
             $this->output->addString('| ' . $entry->action_by . ' ' . str_repeat(' ', $padding2));
             $this->output->addString('| ' . $entry->direction . ' ' . ($entry->direction == 'up' ? '  ' : ''));
             $this->output->addLine('| ' . $entry->date . ' |');
         }
         $this->output->addLine(' ' . str_repeat('-', $width));
     } else {
         $this->addLine('No history to display.');
     }
 }
コード例 #2
0
ファイル: Migration.php プロジェクト: mined-gatech/framework
 /**
  * Report migration run info
  *
  * @museDescription  Shows a history of previously run migrations
  *
  * @return  void
  **/
 public function history()
 {
     $migration = new \Hubzero\Content\Migration();
     $history = $migration->history();
     $items = [];
     $maxFile = 0;
     $maxUser = 0;
     $maxScope = 0;
     if ($history && count($history) > 0) {
         $items[] = ['File', 'By', 'Direction', 'Date'];
         foreach ($history as $entry) {
             $items[] = [$entry->scope . DS . $entry->file, $entry->action_by, $entry->direction, $entry->date];
         }
         $this->output->addTable($items, true);
     } else {
         $this->addLine('No history to display.');
     }
 }