當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityManager::getMetadataFactory方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\EntityManager::getMetadataFactory方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityManager::getMetadataFactory方法的具體用法?PHP EntityManager::getMetadataFactory怎麽用?PHP EntityManager::getMetadataFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\EntityManager的用法示例。


在下文中一共展示了EntityManager::getMetadataFactory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: convert

 public function convert($cacheDir)
 {
     $fs = new Filesystem();
     $targetDir = $cacheDir . '/js_entities';
     $webDir = $this->kernel->getRootDir() . '/../web/js';
     $fs->mkdir($targetDir);
     $fs->mkdir($webDir);
     $namespaces = [];
     $metas = $this->entityManager->getMetadataFactory()->getAllMetadata();
     foreach ($metas as $metadata) {
         $meta = $this->convertMetadata($metadata);
         $directory = $targetDir . '/' . $meta->namespace;
         $fs->mkdir($directory);
         $meta->filename = $directory . '/' . $meta->functionName . '.js';
         $this->generator->generateEntity($meta);
         if (!isset($namespaces[$meta->namespace])) {
             $namespaces[$meta->namespace] = array();
         }
         $namespaces[$meta->namespace][] = $meta;
     }
     foreach ($namespaces as $namespace => $metas) {
         $targetFile = $targetDir . '/' . $namespace . '.js';
         $webFile = $webDir . '/' . $namespace . '.js';
         $this->generator->generateNamespace($namespace, $metas, $targetFile);
         $fs->copy($targetFile, $webFile);
     }
 }
開發者ID:CornyPhoenix,項目名稱:JsEntitiesBundle,代碼行數:27,代碼來源:JsEntityConverter.php

示例2: boot

 /**
  * @throws \Doctrine\ORM\ORMException
  */
 public function boot()
 {
     $this->serializer = SerializerBuilder::create()->setDebug($this->devMode)->build();
     $this->entityFolder->create();
     AnnotationRegistry::registerAutoloadNamespace('JMS\\Serializer\\Annotation', __DIR__ . '/../../../../vendor/jms/serializer/src');
     $proxyDoctrineFolder = new Folder(sys_get_temp_dir() . '/doctrine');
     $config = Setup::createAnnotationMetadataConfiguration([$this->entityFolder->absolute()], $this->isDevMode(), $proxyDoctrineFolder->absolute());
     if ($this->cache !== null) {
         $config->setQueryCacheImpl($this->getCache());
         $config->setResultCacheImpl($this->getCache());
     }
     $this->entityManager = $this->createEntityManager($config);
     $debugStack = new DebugStack();
     $this->entityManager->getConnection()->getConfiguration()->setSQLLogger($debugStack);
     if ($this->getFileCreation()->getContent() == 1) {
         return;
     }
     if ($proxyDoctrineFolder->isFolder()) {
         $proxyDoctrineFolder->removeFiles();
     }
     $tool = new SchemaTool($this->entityManager);
     $metadatas = $this->entityManager->getMetadataFactory()->getAllMetadata();
     $proxyDoctrineFolder->create();
     $this->entityManager->getProxyFactory()->generateProxyClasses($metadatas, $proxyDoctrineFolder->absolute());
     if ($this->cloudFoundryBoot->isInCloudFoundry()) {
         $tool->updateSchema($metadatas);
     } else {
         $tool->createSchema($metadatas);
     }
     $this->getFileCreation()->setContent(1);
 }
開發者ID:cloudfoundry-community,項目名稱:php-cf-service-broker,代碼行數:34,代碼來源:DoctrineBoot.php

示例3: purge

 /**
  * {@inheritdoc}
  */
 public function purge()
 {
     $classes = array();
     $metadatas = $this->em->getMetadataFactory()->getAllMetadata();
     foreach ($metadatas as $metadata) {
         if (!$metadata->isMappedSuperclass) {
             $classes[] = $metadata;
         }
     }
     $commitOrder = $this->getCommitOrder($this->em, $classes);
     // Drop association tables first
     $orderedTables = $this->getAssociationTables($commitOrder);
     // Get platform parameters
     $platform = $this->em->getConnection()->getDatabasePlatform();
     // Drop tables in reverse commit order
     for ($i = count($commitOrder) - 1; $i >= 0; --$i) {
         $class = $commitOrder[$i];
         if ($class->isInheritanceTypeSingleTable() && $class->name != $class->rootEntityName || $class->isMappedSuperclass) {
             continue;
         }
         $orderedTables[] = $class->getQuotedTableName($platform);
     }
     $orderedTables = array_diff($orderedTables, $this->excludedTables);
     foreach ($orderedTables as $tbl) {
         if ($this->purgeMode === self::PURGE_MODE_DELETE) {
             $this->em->getConnection()->executeUpdate("DELETE FROM " . $tbl);
         } else {
             $this->em->getConnection()->executeUpdate($platform->getTruncateTableSQL($tbl, true));
         }
     }
 }
開發者ID:javiersantos,項目名稱:pim-community-dev,代碼行數:34,代碼來源:SelectiveORMPurger.php

示例4: loadClassMetadata

 /**
  * @param LoadClassMetadataEventArgs $args
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $args)
 {
     $this->em = $args->getEntityManager();
     $this->meta = $args->getClassMetadata();
     if (!$this->em->getConnection()->getWrappedConnection() instanceof AbstractConnection) {
         return;
     }
     if ($this->meta->customPersisterClassName === null) {
         $this->meta->setCustomPersisterClass(EntityPersister::class);
     }
     $this->markIndex();
     foreach ($this->meta->fieldMappings as $property => &$mapping) {
         $this->remapIdentifier($property, $mapping);
         $this->remapVersion($property, $mapping);
         $this->markField($property, $mapping);
     }
     foreach ($this->meta->associationMappings as $property => &$mapping) {
         $this->remapAnyToOneAssociation($property, $mapping);
         $this->remapAnyToManyAssociation($property, $mapping);
         $this->remapManyToManyAssociation($property, $mapping);
     }
     if ($cache = $this->em->getMetadataFactory()->getCacheDriver()) {
         $cache->save($this->meta->name . '$CLASSMETADATA', $this->meta, null);
     }
 }
開發者ID:mihai-stancu,項目名稱:orientdb-orm,代碼行數:28,代碼來源:OrientDBListener.php

示例5: getExtensionMetadata

 /**
  * Reads extension metadata
  * 
  * @param ClassMetadataInfo $meta
  * @return array - the metatada configuration
  */
 public function getExtensionMetadata(ClassMetadataInfo $meta)
 {
     if ($meta->isMappedSuperclass) {
         return;
         // ignore mappedSuperclasses for now
     }
     $config = array();
     // collect metadata from inherited classes
     foreach (array_reverse(class_parents($meta->name)) as $parentClass) {
         // read only inherited mapped classes
         if ($this->_em->getMetadataFactory()->hasMetadataFor($parentClass)) {
             $this->_driver->readExtendedMetadata($this->_em->getClassMetadata($parentClass), $config);
         }
     }
     $this->_driver->readExtendedMetadata($meta, $config);
     $this->_driver->validateFullMetadata($meta, $config);
     if ($config) {
         // cache the metadata
         $cacheId = self::getCacheId($meta->name, $this->_extensionNamespace);
         if ($cacheDriver = $this->_em->getMetadataFactory()->getCacheDriver()) {
             $cacheDriver->save($cacheId, $config, null);
         }
     }
     return $config;
 }
開發者ID:jgat2012,項目名稱:hp_oms,代碼行數:31,代碼來源:ExtensionMetadataFactory.php

示例6: getMetadata

 public static function getMetadata()
 {
     /** @var EntityManagerInterface $em */
     static::$em = static::$kernel->getContainer()->get('doctrine')->getManager();
     $metadata = static::$em->getMetadataFactory()->getAllMetadata();
     return $metadata;
 }
開發者ID:scaytrase,項目名稱:symfony-test-utils,代碼行數:7,代碼來源:FixtureTestCase.php

示例7: resetDatabase

 public function resetDatabase()
 {
     $metadatas = $this->em->getMetadataFactory()->getAllMetadata();
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $tool->dropDatabase();
     $tool->createSchema($metadatas);
 }
開發者ID:dstansby,項目名稱:camdram,代碼行數:7,代碼來源:DatabaseTools.php

示例8: __construct

 public function __construct(EntityManager $em, $currencyClassName)
 {
     $this->em = $em;
     $this->currencyClassName = $currencyClassName;
     if (!$currencyClassName || !$this->em->getMetadataFactory()->hasMetadataFor($currencyClassName) && !$this->em->getClassMetadata($currencyClassName)) {
         throw new \Exception("Class for currency \"{$currencyClassName}\" not found");
     }
 }
開發者ID:remedge,項目名稱:redcode-currency-rate-bundle,代碼行數:8,代碼來源:CurrencyManager.php

示例9: init

 protected function init()
 {
     $this->em = $this->app['em'];
     $this->connection = $this->em->getConnection();
     $this->schemaManager = $this->em->getConnection()->getSchemaManager();
     $this->schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $this->validator = new \Doctrine\ORM\Tools\SchemaValidator($this->em);
     $this->metadatas = $this->em->getMetadataFactory()->getAllMetadata();
 }
開發者ID:elfet,項目名稱:silicone,代碼行數:9,代碼來源:Command.php

示例10: generateSchema

 /**
  * @return null
  */
 protected function generateSchema()
 {
     $metadatas = $this->em->getMetadataFactory()->getAllMetadata();
     if (!empty($metadatas)) {
         $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
         $tool->dropSchema($metadatas);
         $tool->createSchema($metadatas);
     }
 }
開發者ID:victorhaggqvist,項目名稱:SettingsBundle,代碼行數:12,代碼來源:AbstractTest.php

示例11: createSchema

 private function createSchema()
 {
     $this->getProvider()->deleteDatabase($this->getDatabaseName());
     $schemaTool = new SchemaTool($this->entityManager);
     $schemaTool->createSchema($this->entityManager->getMetadataFactory()->getAllMetadata());
     $this->loadFixtures();
     $this->getProvider()->backupDatabase($this->getDatabaseName());
     self::$schemaExists = true;
 }
開發者ID:outeredge,項目名稱:edge-zf2,代碼行數:9,代碼來源:AbstractDoctrineServiceTestCase.php

示例12: getEntityClassesFromEntityManager

 /**
  * @return array
  */
 protected function getEntityClassesFromEntityManager()
 {
     $entityClasses = [];
     $metaData = $this->entityManager->getMetadataFactory()->getAllMetadata();
     foreach ($metaData as $classMetaData) {
         $entityClasses[] = $classMetaData->getName();
     }
     return $entityClasses;
 }
開發者ID:pmill,項目名稱:doctrine-rest-api,代碼行數:12,代碼來源:Doctrine.php

示例13: getManagedEntities

 /**
  * @return ChoiceQuestion
  */
 protected function getManagedEntities()
 {
     $metadata = $this->em->getMetadataFactory()->getAllMetadata();
     $entities = [];
     /** @var ClassMetadata $meta */
     foreach ($metadata as $index => $meta) {
         $entities[$index] = $meta->getReflectionClass()->getName();
     }
     return $entities;
 }
開發者ID:bitecodes,項目名稱:factrine-bundle,代碼行數:13,代碼來源:FactrineSeedEntityCommand.php

示例14: setUp

 public function setUp()
 {
     $dbParams = array('dbname' => 'metamodel_test', 'memory' => 'true', 'driver' => 'pdo_sqlite');
     $config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/Fixture"), true);
     $this->em = EntityManager::create($dbParams, $config);
     $tool = new SchemaTool($this->em);
     $tool->createSchema($this->em->getMetadataFactory()->getAllMetadata());
     $this->metaModel = new MetaModel();
     $this->metaModel->addObjectManager(new EntityManagerBridge($this->em));
 }
開發者ID:mnapoli,項目名稱:metamodel,代碼行數:10,代碼來源:QueryTest.php

示例15: setUp

 protected function setUp()
 {
     parent::setUp();
     if (!isset(static::$_sharedConn)) {
         static::$_sharedConn = $this->_getDefaultConnection();
     }
     $this->_em = $this->_getTestEntityManager(static::$_sharedConn);
     $this->_schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->_em);
     $this->_schemaTool->createSchema($this->_em->getMetadataFactory()->getAllMetadata());
 }
開發者ID:jdrich,項目名稱:drest,代碼行數:10,代碼來源:DrestFunctionalTestCase.php


注:本文中的Doctrine\ORM\EntityManager::getMetadataFactory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。