Example #1
0
 /**
  * @param Debugger           $debugger
  * @param ODM                $odm
  * @param ContainerInterface $container
  * @param ClassLocator       $locator
  */
 public function perform(Debugger $debugger, ODM $odm, ContainerInterface $container, ClassLocator $locator)
 {
     //We don't really need location errors here
     $locator->setLogger(new NullLogger());
     $benchmark = $debugger->benchmark($this, 'update');
     $builder = $odm->schemaBuilder($locator);
     //To make builder available for other commands (in sequence)
     $container->bind(get_class($builder), $builder);
     if (!$this->option('sync')) {
         $this->writeln("<comment>Silent mode on, no mongo indexes to be created.</comment>");
     }
     //Save and syncronize
     $odm->updateSchema($builder, $this->option('sync'));
     $elapsed = number_format($debugger->benchmark($this, $benchmark), 3);
     $countModels = count($builder->getDocuments());
     $this->write("<info>ODM Schema has been updated: <comment>{$elapsed} s</comment>");
     $this->writeln(", found documents: <comment>{$countModels}</comment></info>");
 }
Example #2
0
 /**
  * Create instance of inspector associated with ORM and ODM entities.
  *
  * @param InspectionsConfig $config
  * @param ODM               $odm
  * @param ORM               $orm
  * @return Inspector
  */
 protected function createInspector(InspectionsConfig $config, ODM $odm, ORM $orm)
 {
     if ($this->container->has(\Spiral\ODM\Entities\SchemaBuilder::class)) {
         $odmBuilder = $this->container->get(\Spiral\ODM\Entities\SchemaBuilder::class);
     } else {
         $odmBuilder = $odm->schemaBuilder();
     }
     if ($this->container->has(\Spiral\ORM\Entities\SchemaBuilder::class)) {
         $ormBuilder = $this->container->get(\Spiral\ORM\Entities\SchemaBuilder::class);
     } else {
         $ormBuilder = $orm->schemaBuilder();
     }
     return new Inspector($config, array_merge($odmBuilder->getDocuments(), $ormBuilder->getRecords()));
 }
Example #3
0
 /**
  * @param FilesInterface $files
  * @param ODM            $odm
  */
 public function perform(FilesInterface $files, ODM $odm)
 {
     $umlExporter = new UmlExporter($odm->schemaBuilder());
     $files->write($this->argument('filename'), $umlExporter->generate());
     $this->writeln("<info>UML schema has been  successfully exported:</info> {$this->argument('filename')}");
 }