예제 #1
0
 public function execute(InputStream $in, OutputStream $out)
 {
     $out->write($in->getArgument('--boolean'));
     $out->write($in->getArgument('string'));
     $out->write(implode("-", $in->getArgument('array')));
     $out->flush();
 }
예제 #2
0
 /**
  *
  * @param OutputStream $out
  * @throws \Exception
  */
 public function downgradeOperation(OutputStream $out)
 {
     $currentVersion = 0;
     if (file_exists($this->getSavePath())) {
         $currentVersion = file_get_contents($this->getSavePath());
     }
     $migrateFiles = array();
     $handleDir = opendir($this->getStagePath());
     while ($file = readdir($handleDir)) {
         if ($file != "." && $file != ".." && preg_match('/^Version([0-9]+)\\.php$/', $file, $match)) {
             $migrateFiles[] = $match[1];
         }
     }
     $versionBefore = $currentVersion;
     rsort($migrateFiles);
     foreach ($migrateFiles as $migrateFile) {
         try {
             if ($migrateFile <= $currentVersion) {
                 $versionFile = $this->getStagePath() . '/Version' . $migrateFile . '.php';
                 /** @noinspection PhpIncludeInspection */
                 require_once $versionFile;
                 $versionClassName = 'Migrate\\Version' . $migrateFile;
                 $versionObject = new $versionClassName();
                 /**
                  * @var MigrateStage $versionObject
                  */
                 $versionObject->down($this->container);
                 $currentVersion = $migrateFile;
                 file_put_contents($this->getSavePath(), $currentVersion);
             }
         } catch (\Exception $e) {
             throw new \Exception("Error in version " . $migrateFile . "(" . $e->getLine() . ") [downgrade]: " . $e->getMessage());
         }
     }
     $currentVersion = 0;
     file_put_contents($this->getSavePath(), $currentVersion);
     $out->write("Modified version " . $versionBefore . " to " . $currentVersion);
     $out->flush();
 }
예제 #3
0
 public function execute(InputStream $in, OutputStream $out)
 {
     $out->write($this->testService->getText() . ' ' . $in->getArgument('--name'));
     $out->flush();
 }