当前位置: 首页>>代码示例>>PHP>>正文


PHP ManagerRegistry::getManagerNames方法代码示例

本文整理汇总了PHP中Doctrine\Common\Persistence\ManagerRegistry::getManagerNames方法的典型用法代码示例。如果您正苦于以下问题:PHP ManagerRegistry::getManagerNames方法的具体用法?PHP ManagerRegistry::getManagerNames怎么用?PHP ManagerRegistry::getManagerNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\Persistence\ManagerRegistry的用法示例。


在下文中一共展示了ManagerRegistry::getManagerNames方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addPaths

 /**
  * @param array      $paths
  * @param bool|false $connection
  */
 public function addPaths(array $paths = [], $connection = false)
 {
     $connections = $connection ? [$connection] : $this->registry->getManagerNames();
     foreach ($connections as $connection) {
         $this->getMetaDataDriver($connection)->addPaths($paths);
     }
 }
开发者ID:ryan-senn,项目名称:orm,代码行数:11,代码来源:DoctrineManager.php

示例2: fire

 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  */
 public function fire(ManagerRegistry $registry)
 {
     $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
     foreach ($names as $name) {
         $em = $registry->getManager($name);
         $cache = $em->getConfiguration()->getQueryCacheImpl();
         if (!$cache) {
             throw new InvalidArgumentException('No Result cache driver is configured on given EntityManager.');
         }
         if ($cache instanceof ApcCache) {
             throw new LogicException("Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI.");
         }
         if ($cache instanceof XcacheCache) {
             throw new LogicException("Cannot clear XCache Cache from Console, its shared in the Webserver memory and not accessible from the CLI.");
         }
         $this->message('Clearing result cache entries for <info>' . $name . '</info> entity manager');
         $result = $cache->deleteAll();
         $message = $result ? 'Successfully deleted cache entries.' : 'No cache entries were deleted.';
         if ($this->option('flush')) {
             $result = $cache->flushAll();
             $message = $result ? 'Successfully flushed cache entries.' : $message;
         }
         $this->info($message);
     }
 }
开发者ID:Devitek,项目名称:orm,代码行数:30,代码来源:ClearQueryCacheCommand.php

示例3: fire

 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  */
 public function fire(ManagerRegistry $registry)
 {
     $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
     foreach ($names as $name) {
         $em = $registry->getManager($name);
         $validator = new SchemaValidator($em);
         $this->comment('');
         $this->message('Validating for <info>' . $name . '</info> entity manager...');
         if ($this->option('skip-mapping')) {
             $this->comment('Mapping]  Skipped mapping check.');
         } elseif ($errors = $validator->validateMapping()) {
             foreach ($errors as $className => $errorMessages) {
                 $this->error("[Mapping]  FAIL - The entity-class '" . $className . "' mapping is invalid:");
                 $this->comment('');
                 foreach ($errorMessages as $errorMessage) {
                     $this->message('* ' . $errorMessage, 'red');
                 }
             }
         } else {
             $this->info('[Mapping]  OK - The mapping files are correct.');
         }
         if ($this->option('skip-sync')) {
             $this->comment('Database] SKIPPED - The database was not checked for synchronicity.');
         } elseif (!$validator->schemaInSyncWithMetadata()) {
             $this->error('[Database] FAIL - The database schema is not in sync with the current mapping file.');
         } else {
             $this->info('[Database] OK - The database schema is in sync with the mapping files.');
         }
     }
 }
开发者ID:rosstuck,项目名称:Laravel-Doctrine,代码行数:35,代码来源:SchemaValidateCommand.php

示例4: fire

 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  */
 public function fire(ManagerRegistry $registry)
 {
     $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
     foreach ($names as $name) {
         $em = $registry->getManager($name);
         try {
             $em->getConfiguration()->ensureProductionSettings();
             if ($this->option('with-db')) {
                 $em->getConnection()->connect();
             }
         } catch (Exception $e) {
             $this->error('Error for ' . $name . ' entity manager');
             $this->error($e->getMessage());
             return;
         }
         $this->comment('Environment for <info>' . $name . '</info> entity manager is correctly configured for production.');
     }
 }
开发者ID:Devitek,项目名称:orm,代码行数:23,代码来源:EnsureProductionSettingsCommand.php

示例5: fire

 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  */
 public function fire(ManagerRegistry $registry)
 {
     $this->error('ATTENTION: This operation should not be executed in a production environment.');
     $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
     foreach ($names as $name) {
         $em = $registry->getManager($name);
         $tool = new SchemaTool($em);
         $this->info('');
         $this->message('Checking scheme for <info>' . $name . '</info> entity manager...');
         if ($this->option('sql')) {
             if ($this->option('full')) {
                 $sql = $tool->getDropDatabaseSQL();
             } else {
                 $sql = $tool->getDropSchemaSQL($em->getMetadataFactory()->getAllMetadata());
             }
             $this->comment('     ' . implode(';     ' . PHP_EOL, $sql));
         } else {
             if ($this->option('force')) {
                 $this->message('Dropping database schema...');
                 if ($this->option('full')) {
                     $tool->dropDatabase();
                 } else {
                     $tool->dropSchema($em->getMetadataFactory()->getAllMetadata());
                 }
                 $this->info('Database schema dropped successfully!');
             }
             if ($this->option('full')) {
                 $sql = $tool->getDropDatabaseSQL();
             } else {
                 $sql = $tool->getDropSchemaSQL($em->getMetadataFactory()->getAllMetadata());
             }
             if (count($sql)) {
                 $pluralization = 1 === count($sql) ? 'query was' : 'queries were';
                 $this->message(sprintf('The Schema-Tool would execute <info>"%s"</info> %s to update the database.', count($sql), $pluralization));
                 $this->message('Please run the operation by passing one - or both - of the following options:');
                 $this->comment(sprintf('    <info>php artisan %s --force</info> to execute the command', $this->getName()));
                 $this->comment(sprintf('    <info>php artisan %s --sql</info> to dump the SQL statements to the screen', $this->getName()));
             } else {
                 $this->error('Nothing to drop. The database is empty!');
             }
         }
     }
 }
开发者ID:Devitek,项目名称:orm,代码行数:48,代码来源:SchemaDropCommand.php

示例6: fire

 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  */
 public function fire(ManagerRegistry $registry)
 {
     $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
     if (!$this->option('sql')) {
         $this->error('ATTENTION: This operation should not be executed in a production environment.');
     }
     foreach ($names as $name) {
         $em = $registry->getManager($name);
         $tool = new SchemaTool($em);
         $this->message('Creating database schema for <info>' . $name . '</info> entity manager...', 'blue');
         if ($this->option('sql')) {
             $sql = $tool->getCreateSchemaSql($em->getMetadataFactory()->getAllMetadata());
             $this->comment('     ' . implode(';     ' . PHP_EOL, $sql));
         } else {
             $tool->createSchema($em->getMetadataFactory()->getAllMetadata());
         }
     }
     $this->info('Database schema created successfully!');
 }
开发者ID:rosstuck,项目名称:Laravel-Doctrine,代码行数:24,代码来源:SchemaCreateCommand.php

示例7: fire

 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  *
  * @throws Exception
  */
 public function fire(ManagerRegistry $registry)
 {
     $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
     foreach ($names as $name) {
         $em = $registry->getManager($name);
         $entityClassNames = $em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames();
         if (!$entityClassNames) {
             throw new Exception('You do not have any mapped Doctrine ORM entities according to the current configuration. ' . 'If you have entities or mapping files you should check your mapping configuration for errors.');
         }
         $this->message(sprintf("Found <info>%d</info> mapped entities for <info>{$name}</info> entity manager:", count($entityClassNames)));
         foreach ($entityClassNames as $entityClassName) {
             try {
                 $em->getClassMetadata($entityClassName);
                 $this->comment(sprintf("<info>[OK]</info>   %s", $entityClassName));
             } catch (MappingException $e) {
                 $this->comment("<error>[FAIL]</error> " . $entityClassName);
                 $this->comment(sprintf("<comment>%s</comment>", $e->getMessage()));
                 $this->comment('');
             }
         }
     }
 }
开发者ID:rosstuck,项目名称:Laravel-Doctrine,代码行数:29,代码来源:InfoCommand.php

示例8: fire

 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  */
 public function fire(ManagerRegistry $registry)
 {
     if (!$this->option('sql') && (!$this->laravel->environment('local') && !$this->option('force'))) {
         $this->error('ATTENTION: This operation should not be executed in a production environment.');
         $this->error('Use the incremental update to detect changes during development and use');
         $this->error('the SQL DDL provided to manually update your database in production.');
     }
     $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
     foreach ($names as $name) {
         $em = $registry->getManager($name);
         $tool = new SchemaTool($em);
         $this->comment('');
         $this->message('Checking if database connected to <info>' . $name . '</info> entity manager needs updating...', 'blue');
         // Check if there are updates available
         $sql = $tool->getUpdateSchemaSql($em->getMetadataFactory()->getAllMetadata(), !$this->option('clean'));
         if (0 === count($sql)) {
             return $this->error('Nothing to update - your database is already in sync with the current entity metadata.');
         }
         if ($this->option('sql')) {
             $this->comment('     ' . implode(';     ' . PHP_EOL, $sql));
         } else {
             if ($this->laravel->environment('local') || $this->option('force')) {
                 $this->message('Updating database schema...', 'blue');
                 $tool->updateSchema($em->getMetadataFactory()->getAllMetadata(), !$this->option('clean'));
                 $pluralization = 1 === count($sql) ? 'query was' : 'queries were';
                 $this->info(sprintf('Database schema updated successfully! "<info>%s</info>" %s executed', count($sql), $pluralization));
             } else {
                 $this->message(sprintf('The Schema-Tool would execute <info>"%s"</info> queries to update the database.', count($sql)));
             }
         }
     }
     if (!$this->option('sql') && (!$this->laravel->environment('local') && !$this->option('force'))) {
         $this->info('');
         $this->message('Please run the operation by passing one - or both - of the following options:');
         $this->comment(sprintf('    <info>php artisan %s --force</info> to execute the command', $this->getName()));
         $this->comment(sprintf('    <info>php artisan %s --sql</info> to dump the SQL statements to the screen', $this->getName()));
     }
 }
开发者ID:Devitek,项目名称:orm,代码行数:43,代码来源:SchemaUpdateCommand.php

示例9: fire

 /**
  * Execute the console command.
  *
  * @param ManagerRegistry $registry
  */
 public function fire(ManagerRegistry $registry)
 {
     $names = $this->option('em') ? [$this->option('em')] : $registry->getManagerNames();
     foreach ($names as $name) {
         $em = $registry->getManager($name);
         $this->comment('');
         $this->message('Generating proxies for <info>' . $name . '</info> entity manager...', 'blue');
         $metadatas = $em->getMetadataFactory()->getAllMetadata();
         $metadatas = MetadataFilter::filter($metadatas, $this->option('filter'));
         // Process destination directory
         if (($destPath = $this->argument('dest-path')) === null) {
             $destPath = $em->getConfiguration()->getProxyDir();
         }
         if (!is_dir($destPath)) {
             mkdir($destPath, 0777, true);
         }
         $destPath = realpath($destPath);
         if (!file_exists($destPath)) {
             throw new InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not exist.", $em->getConfiguration()->getProxyDir()));
         }
         if (!is_writable($destPath)) {
             throw new InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not have write permissions.", $destPath));
         }
         if (count($metadatas)) {
             foreach ($metadatas as $metadata) {
                 $this->comment(sprintf('Processing entity "<info>%s</info>"', $metadata->name));
             }
             // Generating Proxies
             $em->getProxyFactory()->generateProxyClasses($metadatas, $destPath);
             // Outputting information message
             $this->comment(sprintf('Proxy classes generated to "<info>%s</INFO>"', $destPath));
         } else {
             $this->error('No Metadata Classes to process.');
         }
     }
 }
开发者ID:rosstuck,项目名称:Laravel-Doctrine,代码行数:41,代码来源:GenerateProxiesCommand.php

示例10: __construct

 public function __construct(ManagerRegistry $registry, DbalLogger $logger = null)
 {
     $this->connections = $registry->getConnectionNames();
     $this->managers = $registry->getManagerNames();
     $this->logger = $logger;
 }
开发者ID:novaki,项目名称:symfony,代码行数:6,代码来源:DoctrineDataCollector.php

示例11: __construct

 public function __construct(ManagerRegistry $registry)
 {
     $this->registry = $registry;
     $this->connections = $registry->getConnectionNames();
     $this->managers = $registry->getManagerNames();
 }
开发者ID:xabbuh,项目名称:DoctrinePHPCRBundle,代码行数:6,代码来源:PHPCRDataCollector.php

示例12: extendAll

 /**
  * @param string|callable $callback
  */
 public function extendAll($callback)
 {
     foreach ($this->registry->getManagerNames() as $connection) {
         $this->extend($connection, $callback);
     }
 }
开发者ID:Devitek,项目名称:orm,代码行数:9,代码来源:DoctrineManager.php


注:本文中的Doctrine\Common\Persistence\ManagerRegistry::getManagerNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。