本文整理汇总了PHP中Doctrine\Common\Persistence\ManagerRegistry::getManagers方法的典型用法代码示例。如果您正苦于以下问题:PHP ManagerRegistry::getManagers方法的具体用法?PHP ManagerRegistry::getManagers怎么用?PHP ManagerRegistry::getManagers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ManagerRegistry
的用法示例。
在下文中一共展示了ManagerRegistry::getManagers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanUp
public function cleanUp()
{
foreach ($this->managerRegistry->getManagers() as $name => $manager) {
$this->logger->debug('Clear EntityManager', ['entity_manager' => $name]);
$manager->clear();
}
}
示例2: warmUp
/**
* {@inheritdoc}
*/
public function warmUp($cacheDir)
{
$helper = new UniqueNodeTypeHelper();
foreach ($this->registry->getManagers() as $documentManager) {
$helper->checkNodeTypeMappings($documentManager);
}
}
示例3: boot
/**
* 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());
}
}
}
}
示例4: boot
/**
* 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);
}
}
}
示例5: process
/**
* {@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;
}
示例6: cleanUp
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);
}
}
}
示例7: isKnownEntityClassNamespace
/**
* 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;
}
示例8: supports
/**
* {@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;
}
示例9: boot
/**
* 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);
}
}
}
示例10: getMetadata
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
}
}
}
示例11: boot
/**
* 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);
}
}
}
示例12: fromRegistry
/**
* 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);
}
示例13: write
/**
* {@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();
}
示例14: boot
/**
* 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);
}
}
}
示例15: supports
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());
}