Bravo3\Orm\Services\EntityManager::build PHP Méthode

build() public static méthode

Create a new entity manager
public static build ( Bravo3\Orm\Drivers\DriverInterface $driver, Bravo3\Orm\Mappers\MapperInterface $mapper, SerialiserMap $serialiser_map = null, Bravo3\Orm\KeySchemes\KeySchemeInterface $key_scheme = null, Configuration $configuration = null, Bravo3\Orm\Services\Cache\EntityCachingInterface $cache = null ) : EntityManager
$driver Bravo3\Orm\Drivers\DriverInterface
$mapper Bravo3\Orm\Mappers\MapperInterface
$serialiser_map Bravo3\Orm\Serialisers\SerialiserMap
$key_scheme Bravo3\Orm\KeySchemes\KeySchemeInterface
$configuration Bravo3\Orm\Config\Configuration
$cache Bravo3\Orm\Services\Cache\EntityCachingInterface
Résultat EntityManager
    public static function build(DriverInterface $driver, MapperInterface $mapper, SerialiserMap $serialiser_map = null, KeySchemeInterface $key_scheme = null, Configuration $configuration = null, EntityCachingInterface $cache = null)
    {
        $em_conf = $configuration ?: new Configuration();
        $proxy_conf = new \ProxyManager\Configuration();
        $proxy_conf->setProxiesTargetDir($em_conf->getCacheDir());
        $proxy_conf->setProxiesNamespace(Writer::PROXY_NAMESPACE);
        $proxy_factory = new AccessInterceptorValueHolderFactory($proxy_conf);
        $interceptor_factor = new EntityManagerInterceptorFactory();
        $em = new self($driver, $mapper, $serialiser_map, $key_scheme, $em_conf, $cache);
        $proxy = $proxy_factory->createProxy($em, $interceptor_factor->getPrefixInterceptors(), $interceptor_factor->getSuffixInterceptors());
        $em->setProxy($proxy);
        return $proxy;
    }

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\EntityManager::build