public function testFindYmlOnVfs() { $directoryOutput = self::$directoryV->url() . '/output'; if (!file_exists($directoryOutput)) { mkdir($directoryOutput, 0700, true); } $data = file_get_contents(__DIR__ . '/../Resources/finder/basemodel/model.yml'); file_put_contents($directoryOutput . '/test.yml', $data); $finder = new Finder(); $finder->setLogger($this->logger); $finder->search($directoryOutput, 'yml'); $actual = $finder->getFindedFiles(); $this->assertCount(1, $actual, 'yml file not found'); }
protected function execute(InputInterface $input, OutputInterface $output) { // throw new \Exception('boo'); $directory = realpath($input->getArgument('directory')); $directoryOutput = $input->getArgument('outputdirectory'); /* @var $logger Psr\Log\LoggerInterface */ $this->logger = $this->getContainer()->get('logger'); $io = new SymfonyStyle($input, $output); $io->title('DDD Model Generation'); $clean = $input->hasOption('clean'); if ($clean) { $io->section('Clean output directoty'); $fs = new \Symfony\Component\Filesystem\Filesystem(); try { $fs->remove($directoryOutput); } catch (IOExceptionInterface $e) { $io->error($e->getMessage()); } $io->text('clean of ' . $directoryOutput . ' completed'); } if (is_dir($directory)) { $finder = new Finder(); $finder->search($directory); foreach ($finder->getFindedFiles() as $file) { if (pathinfo($file, PATHINFO_FILENAME) == 'model.yml') { $io->text('Analizzo model.yml in ' . pathinfo($file, PATHINFO_DIRNAME)); $dddGenerator = new DDDGenerator(); $dddGenerator->setLogger($this->logger); $dddGenerator->analyze($file); $dddGenerator->generate($directoryOutput); } } $io->section('Php-Cs-Fixer on generated files'); $fixer = new \Symfony\CS\Console\Command\FixCommand(); $input = new ArrayInput(['path' => $directoryOutput, '--level' => 'psr2', '--fixers' => 'eof_ending,strict_param,short_array_syntax,trailing_spaces,indentation,line_after_namespace,php_closing_tag']); $output = new BufferedOutput(); $fixer->run($input, $output); $content = $output->fetch(); $io->text($content); if (count($this->errors) == 0) { $io->success('Completed generation'); } else { $io->error($this->errors); } } else { $io->caution('Directory ' . $directory . ' not valid'); } // PER I WARNING RECUPERABILI //$io->note('Generate Class'); }