Bravo3\Orm\Services\Porter::registerManager PHP Method

registerManager() public method

Register an entity manager
public registerManager ( string $name, EntityManager $manager )
$name string A short name to reference this manager during portation
$manager EntityManager Entity manager with driver to a source/target database
    public function registerManager($name, EntityManager $manager)
    {
        $this->managers[$name] = $manager;
        return $this;
    }

Usage Example

 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @param bool            $export
  * @return void
  */
 protected function port(InputInterface $input, OutputInterface $output, $export = true)
 {
     $entities = $this->getEntities($input->getOption('list'));
     $em = $this->getContainer()->get('orm.em');
     $porter = new Porter(new OutputLogger($output));
     $porter->registerManager('PRIMARY', $em);
     $io = new PharIoDriver($input->getOption($export ? 'output' : 'input'), ArchiveType::memberByKey(strtoupper($input->getOption('format'))));
     $driver = new FilesystemDriver($io);
     $aux = EntityManager::build($driver, $em->getMapper(), $em->getSerialiserMap());
     $porter->registerManager('AUX', $aux);
     $batch_size = max(1, min(1000, (int) $input->getOption('batch')));
     $term = $export ? 'Exporting' : 'Importing';
     foreach ($entities as $class_name) {
         $output->writeln($term . " <info>" . $class_name . "</info>..");
         try {
             if ($export) {
                 $porter->portTable($class_name, 'PRIMARY', 'AUX', $batch_size);
             } else {
                 $porter->portTable($class_name, 'AUX', 'PRIMARY', $batch_size);
             }
         } catch (\Exception $e) {
             $output->writeln("<error>ERROR:</error> " . $e->getMessage());
         }
     }
     if ($export) {
         $output->writeln("<comment>EXPORT COMPLETE</comment>");
     } else {
         $output->writeln("<comment>IMPORT COMPLETE</comment>");
     }
 }
All Usage Examples Of Bravo3\Orm\Services\Porter::registerManager