コード例 #1
0
 /**
  * @param array $files
  */
 public function analyze(array $files)
 {
     $this->output->writeln('Got ' . count($files) . ' files');
     $this->output->writeln('Collect entities...');
     $this->classScanner->parseFilesForClassesAndInterfaces($files);
     $this->definedEntities = $this->classScanner->getDefinedEntities();
     $this->output->writeln('Got ' . count($this->definedEntities) . ' defined entities');
     $this->output->writeln('Check namespaces...');
     $progressbar = new Progressbar($this->output, count($files));
     foreach ($files as $file) {
         $this->analyzeFile($file);
         $progressbar->step();
     }
 }
コード例 #2
0
 /**
  * Write the data out to a file
  *
  * @param string $data The data to write
  * @param Output $output
  */
 private function doDump($data, $output)
 {
     if (!is_dir($dir = dirname($this->targetPath))) {
         $output->writeln('<info>[dir+]</info> ' . $dir);
         if (false === @mkdir($dir, 0777, true)) {
             throw new \RuntimeException('Unable to create directory ' . $dir);
         }
     }
     $output->writeln('<info>[file+]</info> ' . $this->targetPath);
     if (false === @file_put_contents($this->targetPath, $data)) {
         throw new \RuntimeException('Unable to write file ' . $this->targetPath);
     }
     $output->writeln('<info>Output written into ' . $this->targetPath . '</info>');
 }
コード例 #3
0
 /**
  * get configration object for migration script
  *
  * This is based on antromattr/mongodb-migartion code but extends it so we can inject
  * non local stuff centrally.
  *
  * @param string $filepath path to configuration file
  * @param Output $output   ouput interface need by config parser to do stuff
  *
  * @return AntiMattr\MongoDB\Migrations\Configuration\Configuration
  */
 private function getConfiguration($filepath, $output)
 {
     $outputWriter = new OutputWriter(function ($message) use($output) {
         return $output->writeln($message);
     });
     $info = pathinfo($filepath);
     $namespace = 'AntiMattr\\MongoDB\\Migrations\\Configuration';
     $class = $info['extension'] === 'xml' ? 'XmlConfiguration' : 'YamlConfiguration';
     $class = sprintf('%s\\%s', $namespace, $class);
     $configuration = new $class($this->documentManager->getDocumentManager()->getConnection(), $outputWriter);
     // register databsae name before loading to ensure that loading does not fail
     $configuration->setMigrationsDatabaseName($this->databaseName);
     // load additional config from migrations.(yml|xml)
     $configuration->load($filepath);
     return $configuration;
 }