示例#1
0
 /**
  * @param Debugger           $debugger
  * @param ORM                $orm
  * @param ContainerInterface $container
  * @param ClassLocator       $locator
  */
 public function perform(Debugger $debugger, ORM $orm, ContainerInterface $container, ClassLocator $locator)
 {
     //We don't really need location errors here
     $locator->setLogger(new NullLogger());
     $benchmark = $debugger->benchmark($this, 'update');
     $builder = $orm->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 databases to be altered.</comment>");
     }
     $orm->updateSchema($builder, $this->option('sync'));
     $elapsed = number_format($debugger->benchmark($this, $benchmark), 3);
     $countModels = count($builder->getRecords());
     $this->write("<info>ORM Schema has been updated: <comment>{$elapsed} s</comment>");
     $this->writeln(", found records: <comment>{$countModels}</comment></info>");
 }
示例#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()));
 }