Exemplo n.º 1
0
 /**
  * @param FixtureData $f
  * @param string      $path
  * @param bool        $newLine
  *
  * @return int
  */
 private function removeFileItem(FixtureData $f, $path, $newLine = false)
 {
     $this->ioVerbose(function (StyleInterface $io) use($path, $newLine) {
         $io->comment(sprintf('Removing "%s"', $path), $newLine);
     });
     if (false === @unlink($path)) {
         $this->io()->error(sprintf('Could not remove "%s"', $path));
         return 1;
     }
     $f->setEnabled(false);
     return 2;
 }
Exemplo n.º 2
0
 /**
  * @param FixtureData $fixture
  * @param string      $method
  *
  * @return $this
  */
 public function resolve(FixtureData $fixture, $method)
 {
     $r = $this->getSearchRepository();
     $q = $this->getQuery();
     try {
         $this->results = @call_user_func_array([$r, $method], [$fixture->getName(), $q]);
     } catch (\Exception $e) {
     }
     return $this;
 }
Exemplo n.º 3
0
 /**
  * @param FixtureData $f
  */
 private function move(FixtureData $f)
 {
     $f->setName(str_replace(DIRECTORY_SEPARATOR, '-', $f->getName()));
     $tplPathName = uniqid('string_template_' . mt_rand(10, 99) . '_', true);
     $tplFileName = uniqid('string_template_' . mt_rand(10, 99) . '_', true);
     if ($f instanceof FixtureMovieData) {
         list($e, $opts) = $this->moveMovie($f, $this->getTwig(), $tplPathName, $tplFileName);
     } elseif ($f instanceof FixtureEpisodeData) {
         list($e, $opts) = $this->moveEpisode($f, $this->getTwig(), $tplPathName, $tplFileName);
     } else {
         $this->io()->error('Invalid fixture type!');
         return;
     }
     $path = $e->render($tplPathName, $opts);
     $file = $e->render($tplFileName, $opts);
     $outputFilePath = preg_replace('{[/]+}', '/', sprintf('%s/%s/%s', $this->outputPath, $path, $file));
     $outputPath = pathinfo($outputFilePath, PATHINFO_DIRNAME);
     $inputFilePath = $f->getFile()->getRealPath();
     $offset = 2;
     while (true) {
         if (strncmp($outputFilePath, $inputFilePath, $offset++) !== 0) {
             $offset = $offset - 2;
             break;
         }
     }
     $outputFileInfo = new FileInfo($outputFilePath, null, null, false);
     $inputFileInfo = new FileInfo($inputFilePath);
     try {
         $inputFileSize = $inputFileInfo->getSizeHuman();
     } catch (\RuntimeException $e) {
         $inputFileSize = null;
     }
     $tableRows[] = ['Input File', sprintf('[...]%s', basename($inputFilePath)), $inputFileSize];
     try {
         $outputFileSize = $outputFileInfo->getSizeHuman();
     } catch (\RuntimeException $e) {
         $outputFileSize = null;
     }
     $tableRows[] = ['Output File', sprintf('[...]%s', preg_replace('{[/]+}', '/', sprintf('%s/%s', $path, $file))), $outputFileSize];
     $this->io()->table($tableRows, [null, 'Path', 'Size']);
     if (file_exists($outputFilePath) && false === $this->outputOverwrite && false === $this->handleExistingFile($outputFileInfo, $inputFileInfo)) {
         return;
     }
     if (!is_dir($outputPath) && false === @mkdir($outputPath, 0777, true)) {
         $this->io()->error(sprintf('Could not create directory "%s"', $outputPath));
         return;
     }
     if (!$this->io()->isVeryVerbose()) {
         $this->io()->comment(sprintf('Writing "%s"', $outputFilePath), false);
     }
     if (false === @copy($inputFilePath, $outputFilePath)) {
         $this->io()->error(sprintf('Could not write file "%s"', $outputFilePath));
     } else {
         unlink($inputFilePath);
     }
 }
Exemplo n.º 4
0
 /**
  * @return string[]
  */
 public function getFieldsEditable()
 {
     return array_merge(parent::getFieldsEditable(), ['seasonNumber' => 'Season', 'episodeNumberStart' => 'Episode Number', 'title' => 'Episode Title']);
 }
Exemplo n.º 5
0
 /**
  * @return string[]
  */
 public function getFieldsEditable()
 {
     return parent::getFieldsEditable();
 }