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


PHP ClassMetadataExporter::getMetadatas方法代碼示例

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


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

示例1: testTest

 public function testTest()
 {
     $cme = new ClassMetadataExporter();
     $converter = new ConvertDoctrine1Schema(__DIR__ . '/doctrine1schema');
     $exporter = $cme->getExporter('yml', __DIR__ . '/convert');
     $exporter->setMetadatas($converter->getMetadatas());
     $exporter->export();
     $this->assertTrue(file_exists(__DIR__ . '/convert/User.dcm.yml'));
     $this->assertTrue(file_exists(__DIR__ . '/convert/Profile.dcm.yml'));
     $cme->addMappingSource(__DIR__ . '/convert');
     $metadatas = $cme->getMetadatas();
     $this->assertEquals(2, count($metadatas));
     $this->assertEquals('Profile', $metadatas['Profile']->name);
     $this->assertEquals('User', $metadatas['User']->name);
     $this->assertEquals(4, count($metadatas['Profile']->fieldMappings));
     $this->assertEquals(5, count($metadatas['User']->fieldMappings));
     $this->assertEquals('text', $metadatas['User']->fieldMappings['clob']['type']);
     $this->assertEquals('test_alias', $metadatas['User']->fieldMappings['theAlias']['columnName']);
     $this->assertEquals('theAlias', $metadatas['User']->fieldMappings['theAlias']['fieldName']);
     $this->assertEquals('Profile', $metadatas['Profile']->associationMappings['User']->sourceEntityName);
     $this->assertEquals('User', $metadatas['Profile']->associationMappings['User']->targetEntityName);
     $this->assertEquals('username', $metadatas['User']->primaryTable['uniqueConstraints']['username']['columns'][0]);
     unlink(__DIR__ . '/convert/User.dcm.yml');
     unlink(__DIR__ . '/convert/Profile.dcm.yml');
     rmdir(__DIR__ . '/convert');
 }
開發者ID:andreia,項目名稱:doctrine,代碼行數:26,代碼來源:ConvertDoctrine1SchemaTest.php

示例2: run

 public function run()
 {
     $arguments = $this->getArguments();
     $cme = new ClassMetadataExporter();
     $cme->setEntityManager($this->getConfiguration()->getAttribute('em'));
     $printer = $this->getPrinter();
     // Get exporter and configure it
     $exporter = $cme->getExporter($arguments['to'], $arguments['dest']);
     if ($arguments['to'] === 'annotation') {
         $entityGenerator = new EntityGenerator();
         $exporter->setEntityGenerator($entityGenerator);
         if (isset($arguments['extend']) && $arguments['extend']) {
             $entityGenerator->setClassToExtend($arguments['extend']);
         }
         if (isset($arguments['num-spaces']) && $arguments['extend']) {
             $entityGenerator->setNumSpaces($arguments['num-spaces']);
         }
     }
     $from = (array) $arguments['from'];
     foreach ($from as $source) {
         $cme->addMappingSource($source);
     }
     $metadatas = $cme->getMetadatas();
     foreach ($metadatas as $metadata) {
         $printer->writeln(sprintf('Processing entity "%s"', $printer->format($metadata->name, 'KEYWORD')));
     }
     $printer->writeln('');
     $printer->writeln(sprintf('Exporting "%s" mapping information to "%s"', $printer->format($arguments['to'], 'KEYWORD'), $printer->format($arguments['dest'], 'KEYWORD')));
     $exporter->setMetadatas($metadatas);
     $exporter->export();
 }
開發者ID:andreia,項目名稱:doctrine,代碼行數:31,代碼來源:ConvertMappingTask.php

示例3: testExportedMetadataCanBeReadBackIn

 /**
  * @depends testExportDirectoryAndFilesAreCreated
  */
 public function testExportedMetadataCanBeReadBackIn()
 {
     $type = $this->_getType();
     $cme = new ClassMetadataExporter();
     $cme->addMappingSource(__DIR__ . '/export/' . $type, $type);
     $metadataInstances = $cme->getMetadatas();
     $metadata = current($metadataInstances);
     $this->assertEquals($this->_getTestEntityName(), $metadata->name);
     return $metadata;
 }
開發者ID:andreia,項目名稱:doctrine,代碼行數:13,代碼來源:AbstractClassMetadataExporterTest.php


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