public function cleanUp() { foreach ($this->managerRegistry->getManagers() as $name => $manager) { $this->logger->debug('Clear EntityManager', ['entity_manager' => $name]); $manager->clear(); } }
/** * {@inheritdoc} */ public function warmUp($cacheDir) { $helper = new UniqueNodeTypeHelper(); foreach ($this->registry->getManagers() as $documentManager) { $helper->checkNodeTypeMappings($documentManager); } }
/** * Boot the extensions */ public function boot() { foreach ($this->registry->getManagers() as $connection => $em) { foreach ($this->extensions as $extension) { if ($this->notBootedYet($connection, $extension)) { $this->bootExtension($connection, $extension, $em, $em->getEventManager(), $em->getConfiguration()); } } } }
/** * Boot the extensions */ public function boot() { foreach ($this->registry->getManagers() as $em) { $this->em = $em; $this->evm = $this->em->getEventManager(); $this->metadata = $this->em->getConfiguration(); $this->reader = $this->driverChain->getReader(); foreach ($this->extensions as $extension) { $this->bootExtension($extension); } } }
/** * {@inheritdoc} */ public function process(Message $message, array $options) { $result = $this->processor->process($message, $options); foreach ($this->managerRegistry->getManagers() as $managerName => $manager) { if (method_exists($manager, 'isOpen') && !$manager->isOpen()) { $this->managerRegistry->resetManager($managerName); continue; } $manager->clear(); } return $result; }
public function cleanUp() { foreach ($this->managerRegistry->getManagers() as $name => $manager) { if (!$manager instanceof EntityManager) { continue; } if (!$manager->isOpen()) { $this->logger->debug('Reset closed EntityManager', ['entity_manager' => $name]); $this->managerRegistry->resetManager($name); } } }
/** * Checks whether the given namespace is registered in the Doctrine * * @param string $namespace * @return bool */ public function isKnownEntityClassNamespace($namespace) { foreach (array_keys($this->doctrine->getManagers()) as $name) { $manager = $this->doctrine->getManager($name); if ($manager instanceof EntityManager) { $namespaces = $manager->getConfiguration()->getEntityNamespaces(); if (in_array($namespace, $namespaces, true)) { return true; } } } return false; }
/** * {@inheritdoc} */ function supports(ParamConverter $configuration) { if (null === $this->registry || !count($this->registry->getManagers())) { return false; } if (null === $configuration->getClass()) { return false; } $em = $this->registry->getManagerForClass($configuration->getClass()); if ('SensorBundle\\Entity\\Measure' !== $em->getClassMetadata($configuration->getClass())->getName()) { return false; } return true; }
/** * Boot the extensions */ public function boot() { foreach ($this->registry->getManagers() as $em) { $this->em = $em; $this->evm = $this->em->getEventManager(); $this->metadata = $this->em->getConfiguration(); $this->reader = $this->driverChain->getReader(); $hash = spl_object_hash($em); if (!isset($this->subscribedExtensions[$hash])) { $this->subscribedExtensions[$hash] = []; } foreach ($this->extensions as $extension) { $this->bootExtension($extension); } } }
protected function getMetadata($class) { if (array_key_exists($class, $this->cache)) { return $this->cache[$class]; } $this->cache[$class] = null; foreach ($this->registry->getManagers() as $name => $em) { try { return $this->cache[$class] = array($em->getClassMetadata($class), $name); } catch (MappingException $e) { // not an entity or mapped super class } catch (LegacyMappingException $e) { // not an entity or mapped super class, using Doctrine ORM 2.2 } } }
/** * Boot the extensions */ public function boot() { foreach ($this->registry->getManagers() as $em) { $this->em = $em; $this->chain = new MappingDriverChain(); $this->evm = $this->em->getEventManager(); $this->metadata = $this->em->getConfiguration(); $this->reader = method_exists($this->metadata->getMetadataDriverImpl(), 'getReader') ? $this->metadata->getMetadataDriverImpl()->getReader() : false; if ($this->gedmo['enabled']) { $this->bootGedmoExtensions($this->gedmo['namespace'], $this->gedmo['all']); } foreach ($this->extensions as $extenion) { $this->bootExtension($extenion); } } }
/** * Create a driver from a Doctrine registry * * @param ManagerRegistry $registry * @return DriverInterface */ public static function fromRegistry(ManagerRegistry $registry) { $drivers = array(); foreach ($registry->getManagers() as $manager) { $drivers[] = self::fromManager($manager); } return new DriverChain($drivers); }
/** * {@inheritdoc} */ public function write(array $items) { if (is_array(reset($items))) { $items = call_user_func_array('array_merge', $items); } foreach ($items as $item) { if (!is_object($item)) { throw new \InvalidArgumentException(sprintf('Expecting item of type object, got "%s"', gettype($item))); } $this->registry->getManagerForClass(get_class($item))->persist($item); $this->incrementCount($item); } foreach ($this->registry->getManagers() as $manager) { $manager->flush(); } $this->cacheClearer->clear(); }
/** * Boot the service provider * * @param ManagerRegistry $registry */ public function boot(ManagerRegistry $registry) { foreach ($registry->getManagers() as $manager) { $chain = $manager->getConfiguration()->getMetadataDriverImpl(); $reader = $chain->getReader(); if ($this->app->make('config')->get('doctrine.gedmo.all_mappings', false)) { DoctrineExtensions::registerMappingIntoDriverChainORM($chain, $reader); } else { DoctrineExtensions::registerAbstractMappingIntoDriverChainORM($chain, $reader); } } }
public function supports(ConfigurationInterface $configuration) { // if there is no manager, this means that only Doctrine DBAL is configured if (null === $this->registry || !count($this->registry->getManagers())) { return false; } if (null === $configuration->getClass()) { return false; } $options = $this->getOptions($configuration); // Doctrine Entity? return !$this->registry->getManager($options['entity_manager'])->getMetadataFactory()->isTransient($configuration->getClass()); }
/** * @param array $hydrators * @param ManagerRegistry $doctrine * @param Stopwatch|null $stopwatch */ public function __construct(array $hydrators, ManagerRegistry $doctrine, Stopwatch $stopwatch = null) { // inject profiling logger and logging hydrators into a configuration of all registered entity managers foreach ($doctrine->getManagers() as $manager) { if ($manager instanceof EntityManagerInterface) { $configuration = $manager->getConfiguration(); if ($configuration instanceof OrmConfiguration) { $configuration->setAttribute('OrmProfilingLogger', $this); $configuration->setAttribute('LoggingHydrators', $hydrators); } } } $this->stopwatch = $stopwatch; }
private function foreachObjectManagers($callback) { array_map($callback, $this->managerRegistry->getManagers()); }