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


PHP ObjectManager::getMetadataFactory方法代码示例

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


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

示例1: __construct

 /**
  * Initializes context.
  *
  * @param ManagerRegistry $doctrine
  */
 public function __construct(ManagerRegistry $doctrine)
 {
     $this->manager = $doctrine->getManager();
     $this->schemaTool = new SchemaTool($this->manager);
     $this->classes = $this->manager->getMetadataFactory()->getAllMetadata();
     $this->inspector = new JsonInspector('javascript');
 }
开发者ID:aitboudad,项目名称:LoopBackApiBundle,代码行数:12,代码来源:FeatureContext.php

示例2: __construct

 /**
  * Initializes context.
  *
  * Every scenario gets its own context instance.
  * You can also pass arbitrary arguments to the
  * context constructor through behat.yml.
  */
 public function __construct(ManagerRegistry $doctrine)
 {
     $this->doctrine = $doctrine;
     $this->manager = $doctrine->getManager();
     $this->schemaTool = new SchemaTool($this->manager);
     $this->classes = $this->manager->getMetadataFactory()->getAllMetadata();
 }
开发者ID:achreftlili,项目名称:Project,代码行数:14,代码来源:FeatureContext.php

示例3: createSchema

 /**
  * Create the database schema.
  *
  * @param ObjectManager $om
  */
 protected function createSchema(ObjectManager $om)
 {
     if ($om instanceof \Doctrine\ORM\EntityManager) {
         $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($om);
         $schemaTool->createSchema($om->getMetadataFactory()->getAllMetadata());
     } elseif ($om instanceof \Doctrine\ODM\MongoDB\DocumentManager) {
         $sm = new \Doctrine\ODM\MongoDB\SchemaManager($om, $om->getMetadataFactory());
         $sm->createCollections();
     }
 }
开发者ID:robertokazik,项目名称:LexikTranslationBundle,代码行数:15,代码来源:BaseUnitTestCase.php

示例4: __construct

 /**
  * Initializes context.
  *
  * Every scenario gets its own context instance.
  * You can also pass arbitrary arguments to the
  * context constructor through behat.yml.
  *
  * @param ManagerRegistry         $doctrine
  * @param JWTManagerInterface     $jwtManager
  * @param UserManager             $userManager
  * @param EncoderFactoryInterface $encoderFactory
  */
 public function __construct(ManagerRegistry $doctrine, JWTManagerInterface $jwtManager, UserManager $userManager, EncoderFactoryInterface $encoderFactory)
 {
     $this->doctrine = $doctrine;
     $this->manager = $doctrine->getManager();
     $this->schemaTool = new SchemaTool($this->manager);
     $this->metadata = $this->manager->getMetadataFactory()->getAllMetadata();
     $this->jwtManager = $jwtManager;
     $this->userManager = $userManager;
     $this->encoderFactory = $encoderFactory;
     $this->inspector = new JsonInspector('javascript');
 }
开发者ID:EllynB,项目名称:Incipio,代码行数:23,代码来源:ApiContext.php

示例5: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     static::$kernel = static::createKernel();
     static::$kernel->boot();
     $this->doctrine = static::$kernel->getContainer()->get('doctrine');
     $this->doctrineManager = $this->doctrine->getManager();
     $this->validator = static::$kernel->getContainer()->get('validator');
     // Recreate a fresh database instance before each test case
     $metadata = $this->doctrineManager->getMetadataFactory()->getAllMetadata();
     $schemaTool = new SchemaTool($this->doctrineManager);
     $schemaTool->dropSchema($metadata);
     $schemaTool->createSchema($metadata);
 }
开发者ID:EllynB,项目名称:Incipio,代码行数:16,代码来源:AbstractEntityTestCase.php

示例6: setUp

 protected function setUp()
 {
     if (!class_exists('Twig_Environment')) {
         $this->markTestSkipped('Twig is not available.');
     }
     if (null === $this->em) {
         $this->em = $this->client->getContainer()->get('doctrine')->getManager();
         if (!static::$schemaSetUp) {
             $st = new SchemaTool($this->em);
             $classes = $this->em->getMetadataFactory()->getAllMetadata();
             $st->dropSchema($classes);
             $st->createSchema($classes);
             static::$schemaSetUp = true;
         }
     }
     parent::setUp();
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:17,代码来源:WebTestCase.php

示例7: load

 public function load(ObjectManager $manager, $tags = null)
 {
     if (!$this->hasTag($tags)) {
         return;
     }
     $cmf = $manager->getMetadataFactory();
     // The model class for all fixtures defined in this file
     $class = $this->file['model'];
     // Get the fields that are not "associations"
     $metadata = $cmf->getMetaDataFor($class);
     $mapping = array_keys($metadata->fieldMappings);
     $associations = array_keys($metadata->associationMappings);
     foreach ($this->file['fixtures'] as $reference => $fixture) {
         // Instantiate new object
         $object = new $class();
         foreach ($fixture as $field => $value) {
             // Add the fields defined in the fistures file
             $method = Inflector::camelize('set_' . $field);
             //
             if (strpos($value, '$') === 0) {
                 // custom reference loader format: $<referencedEntityKey>|<referencedColumn>
                 // ex: $first_campaign|idcampaign
                 list($referencedEntity, $referenceColumn) = explode('|', ltrim($value, '$'));
                 $getterMethod = Inflector::camelize('get_' . $referenceColumn);
                 $object->{$method}($this->loader->getReference($referencedEntity)->{$getterMethod}());
             } elseif (in_array($field, $mapping)) {
                 // Dates need to be converted to DateTime objects
                 $type = $metadata->fieldMappings[$field]['type'];
                 if ($type == 'datetime' or $type == 'date') {
                     $value = new \DateTime($value);
                 }
                 $object->{$method}($value);
             } else {
                 if (in_array($field, $associations)) {
                     // This field is an association, we load it from the references
                     $object->{$method}($this->loader->getReference($value));
                 } else {
                     // It's a method call that will set a field named differently
                     // eg: FOSUserBundle ->setPlainPassword sets the password after
                     // Encrypting it
                     $object->{$method}($value);
                 }
             }
         }
         // Save a reference to the current object
         $this->loader->setReference($reference, $object);
         if (!$this->isReverseSaveOrder()) {
             $manager->persist($object);
         }
     }
     if ($this->isReverseSaveOrder()) {
         $refs = array_keys($this->file['fixtures']);
         for ($i = count($refs) - 1; $i >= 0; $i--) {
             $manager->persist($this->loader->getReference($refs[$i]));
         }
     }
     $manager->flush();
 }
开发者ID:rombob,项目名称:KhepinYamlFixturesBundle,代码行数:58,代码来源:YamlFixture.php

示例8: getAllEntities

 /**
  * Get all entities
  * 
  * @access public
  * 
  * @return array entities
  */
 public function getAllEntities()
 {
     $entities = array();
     $allMetadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
     foreach ($allMetadata as $entityMetadata) {
         $entities[] = $entityMetadata->getName();
     }
     return $entities;
 }
开发者ID:camelcasetechsd,项目名称:certigate,代码行数:16,代码来源:Query.php

示例9: createData

 private function createData(ObjectManager $manager)
 {
     $data = array('entities' => array(), 'relations' => array());
     $passes = array(new ImportMetadataPass(), new InheritancePass(), new ShortNamePass());
     foreach ($passes as $pass) {
         $data = $pass->process($manager->getMetadataFactory(), $data);
     }
     return $data;
 }
开发者ID:jverdeyen-forks,项目名称:doctrine-extra-bundle,代码行数:9,代码来源:DoctrineMetadataGraph.php

示例10: isEntitySupported

 /**
  * Checks whether provided entity is supported by the Metadatable Controller.
  *
  * @param mixed $entity
  *
  * @return bool
  */
 protected function isEntitySupported($entity)
 {
     try {
         $classMetadata = $this->om->getMetadataFactory()->getMetadataFor(get_class($entity));
     } catch (\Exception $e) {
         return false;
     }
     $reflClass = $classMetadata->reflClass;
     $traitNames = [];
     while ($reflClass) {
         $traitNames = array_merge($traitNames, $reflClass->getTraitNames());
         $reflClass = $reflClass->getParentClass();
     }
     $supported = in_array('Unifik\\DoctrineBehaviorsBundle\\Model\\Metadatable\\Metadatable', $traitNames);
     if (!$supported && is_callable([$entity, 'getTranslation'])) {
         return $this->isEntitySupported($entity->getTranslation());
     }
     return $supported;
 }
开发者ID:smart85,项目名称:UnifikDoctrineBehaviorsBundle,代码行数:26,代码来源:MetadatableGetter.php

示例11: isCorrectClassName

 /**
  * @param string $entityName
  *
  * @return bool
  */
 protected function isCorrectClassName($entityName)
 {
     try {
         $classMetadata = $this->em->getMetadataFactory()->getMetadataFor($entityName);
         $classMetadata->getName();
     } catch (\Exception $e) {
         return false;
     }
     return true;
 }
开发者ID:ramunasd,项目名称:platform,代码行数:15,代码来源:CommentApiManager.php

示例12: __construct

 /**
  * Initializes extension driver.
  *
  * @param \Doctrine\Common\Persistence\ObjectManager $objectManager
  * @param string $extensionNamespace
  * @param object $annotationReader
  */
 public function __construct(ObjectManager $objectManager, $extensionNamespace, $annotationReader)
 {
     $this->objectManager = $objectManager;
     $this->annotationReader = $annotationReader;
     $this->extensionNamespace = $extensionNamespace;
     $omDriver = $objectManager->getConfiguration()->getMetadataDriverImpl();
     $omCache = $this->objectManager->getMetadataFactory()->getCacheDriver();
     $metadataClassName = null;
     if (class_exists($this->extensionNamespace . '\\Mapping\\ClassMetadata')) {
         $metadataClassName = $this->extensionNamespace . '\\Mapping\\ClassMetadata';
     }
     $driver = $this->getDriver($omDriver);
     $driver->setBaseMetadataFactory($objectManager->getMetadataFactory());
     parent::__construct($driver, $omCache, $extensionNamespace, $metadataClassName);
 }
开发者ID:norzechowicz,项目名称:doctrine-extensions,代码行数:22,代码来源:ExtendedMetadataFactory.php

示例13: compile

 /**
  * Called from functional tests, creates/updates database tables and compiles proxies.
  *
  * @return boolean
  */
 public function compile()
 {
     // "driver" is used only for Doctrine, thus we (mis-)use it here
     // additionally, when no path is set, skip this step, assuming no DB is needed
     if ($this->settings['backendOptions']['driver'] !== null && $this->settings['backendOptions']['path'] !== null) {
         $schemaTool = new SchemaTool($this->entityManager);
         if ($this->settings['backendOptions']['driver'] === 'pdo_sqlite') {
             $schemaTool->createSchema($this->entityManager->getMetadataFactory()->getAllMetadata());
         } else {
             $schemaTool->updateSchema($this->entityManager->getMetadataFactory()->getAllMetadata());
         }
         $proxyFactory = $this->entityManager->getProxyFactory();
         $proxyFactory->generateProxyClasses($this->entityManager->getMetadataFactory()->getAllMetadata());
         $this->systemLogger->log('Doctrine 2 setup finished');
         return true;
     } else {
         $this->systemLogger->log('Doctrine 2 setup skipped, driver and path backend options not set!', LOG_NOTICE);
         return false;
     }
 }
开发者ID:neos,项目名称:flow-development-collection,代码行数:25,代码来源:PersistenceManager.php

示例14: generateMigration

 /**
  * Generates a new migration file and returns the path to it.
  *
  * If $diffAgainstCurrent is TRUE, it generates a migration file with the
  * diff between current DB structure and the found mapping metadata.
  *
  * Only include tables/sequences matching the $filterExpression regexp when
  * diffing models and existing schema.
  *
  * Otherwise an empty migration skeleton is generated.
  *
  * @param boolean $diffAgainstCurrent
  * @param string $filterExpression
  * @return string Path to the new file
  */
 public function generateMigration($diffAgainstCurrent = true, $filterExpression = null)
 {
     $configuration = $this->getMigrationConfiguration();
     $up = null;
     $down = null;
     if ($diffAgainstCurrent === true) {
         /** @var \Doctrine\DBAL\Connection $connection */
         $connection = $this->entityManager->getConnection();
         if ($filterExpression) {
             $connection->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
         }
         $metadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
         if (empty($metadata)) {
             return ['No mapping information to process.', null];
         }
         $tool = new SchemaTool($this->entityManager);
         $fromSchema = $connection->getSchemaManager()->createSchema();
         $toSchema = $tool->getSchemaFromMetadata($metadata);
         if ($filterExpression) {
             foreach ($toSchema->getTables() as $table) {
                 $tableName = $table->getName();
                 if (!preg_match($filterExpression, $this->resolveTableName($tableName))) {
                     $toSchema->dropTable($tableName);
                 }
             }
             foreach ($toSchema->getSequences() as $sequence) {
                 $sequenceName = $sequence->getName();
                 if (!preg_match($filterExpression, $this->resolveTableName($sequenceName))) {
                     $toSchema->dropSequence($sequenceName);
                 }
             }
         }
         $platform = $connection->getDatabasePlatform();
         $up = $this->buildCodeFromSql($configuration, $fromSchema->getMigrateToSql($toSchema, $platform));
         $down = $this->buildCodeFromSql($configuration, $fromSchema->getMigrateFromSql($toSchema, $platform));
         if (!$up && !$down) {
             return ['No changes detected in your mapping information.', null];
         }
     }
     return ['Generated new migration class!', $this->writeMigrationClassToFile($configuration, $up, $down)];
 }
开发者ID:fcool,项目名称:flow-development-collection,代码行数:56,代码来源:Service.php

示例15: generateMigration

 /**
  * Generates a new migration file and returns the path to it.
  *
  * If $diffAgainstCurrent is TRUE, it generates a migration file with the
  * diff between current DB structure and the found mapping metadata.
  *
  * Otherwise an empty migration skeleton is generated.
  *
  * @param boolean $diffAgainstCurrent
  * @return string Path to the new file
  */
 public function generateMigration($diffAgainstCurrent = true)
 {
     $configuration = $this->getMigrationConfiguration();
     $up = null;
     $down = null;
     if ($diffAgainstCurrent === true) {
         $connection = $this->entityManager->getConnection();
         $platform = $connection->getDatabasePlatform();
         $metadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
         if (empty($metadata)) {
             return 'No mapping information to process.';
         }
         $tool = new \Doctrine\ORM\Tools\SchemaTool($this->entityManager);
         $fromSchema = $connection->getSchemaManager()->createSchema();
         $toSchema = $tool->getSchemaFromMetadata($metadata);
         $up = $this->buildCodeFromSql($configuration, $fromSchema->getMigrateToSql($toSchema, $platform));
         $down = $this->buildCodeFromSql($configuration, $fromSchema->getMigrateFromSql($toSchema, $platform));
         if (!$up && !$down) {
             return 'No changes detected in your mapping information.';
         }
     }
     return $this->writeMigrationClassToFile($configuration, $up, $down);
 }
开发者ID:patrickreck,项目名称:flow-development-collection,代码行数:34,代码来源:Service.php


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