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


PHP DocumentManager::getClassMetadata方法代码示例

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


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

示例1: setup

 public function setup()
 {
     $this->dm = $this->createDocumentManager();
     $this->session = $this->dm->getPhpcrSession();
     $this->workspace = $this->dm->getPhpcrSession()->getWorkspace();
     $this->metadata = $this->dm->getClassMetadata('Doctrine\\Tests\\Models\\Translation\\Article');
 }
开发者ID:pkdevbox,项目名称:phpcr-odm,代码行数:7,代码来源:ChildTranslationStrategyTest.php

示例2: setUp

 public function setUp()
 {
     $this->dm = $this->createDocumentManager(array(__DIR__));
     $this->node = $this->resetFunctionalNode($this->dm);
     $class = $this->dm->getClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $class->mappings['groups']['cascade'] = ClassMetadata::CASCADE_PERSIST;
     $class = $this->dm->getClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsGroup');
     $class->mappings['users']['cascade'] = ClassMetadata::CASCADE_PERSIST;
     $class = $this->dm->getClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsArticle');
     $class->mappings['user']['cascade'] = ClassMetadata::CASCADE_PERSIST;
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:11,代码来源:CascadePersistTest.php

示例3: setUp

 public function setUp()
 {
     $this->dm = $this->createDocumentManager();
     $this->dm->setLocaleChooserStrategy(new LocaleChooser($this->localePrefs, 'en'));
     $this->node = $this->resetFunctionalNode($this->dm);
     $this->dm->clear();
     $this->session = $this->dm->getPhpcrSession();
     $this->metadata = $this->dm->getClassMetadata($this->class);
     $this->doc = new Article();
     $this->doc->id = '/functional/' . $this->testNodeName;
     $this->doc->author = 'John Doe';
     $this->doc->topic = 'Some interesting subject';
     $this->doc->setText('Lorem ipsum...');
     $this->doc->setSettings(array());
     $this->doc->assoc = array('key' => 'value');
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:16,代码来源:DocumentManagerTest.php

示例4: validateClassName

 /**
  * @param DocumentManager
  * @param object $document
  * @param string $className
  * @throws \InvalidArgumentException
  */
 public function validateClassName(DocumentManager $dm, $document, $className)
 {
     if (!$document instanceof $className) {
         $class = $dm->getClassMetadata(get_class($document));
         $path = $class->getIdentifierValue($document);
         $msg = "Doctrine metadata mismatch! Requested type '{$className}' type does not match type '" . get_class($document) . "' stored in the metadata at path '{$path}'";
         throw new \InvalidArgumentException($msg);
     }
 }
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:15,代码来源:DocumentClassMapper.php

示例5: createRepository

 /**
  * Create a new repository instance for a document class.
  *
  * @param DocumentManager $documentManager The DocumentManager instance.
  * @param string          $documentName    The name of the document.
  *
  * @return \Doctrine\Common\Persistence\ObjectRepository
  */
 protected function createRepository(DocumentManager $documentManager, $documentName)
 {
     $metadata = $documentManager->getClassMetadata($documentName);
     $repositoryClassName = $metadata->customRepositoryClassName;
     if ($repositoryClassName === null) {
         $configuration = $documentManager->getConfiguration();
         $repositoryClassName = $configuration->getDefaultRepositoryClassName();
     }
     return new $repositoryClassName($documentManager, $metadata);
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:18,代码来源:DefaultRepositoryFactory.php

示例6: getFullVersionedNodePath

 private function getFullVersionedNodePath($document)
 {
     $path = $this->getDocumentId($document);
     $metadata = $this->dm->getClassMetadata(get_class($document));
     if ($metadata->versionable !== 'full') {
         throw new \InvalidArgumentException(sprintf("The document at '%s' is not full versionable", $path));
     }
     $node = $this->session->getNode($path);
     $node->addMixin('mix:versionable');
     return $path;
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:11,代码来源:UnitOfWork.php

示例7: getVersionedNodePath

 private function getVersionedNodePath($document)
 {
     $path = $this->getDocumentId($document);
     $metadata = $this->dm->getClassMetadata(get_class($document));
     if (!$metadata->versionable) {
         throw new InvalidArgumentException(sprintf("The document at path '%s' is not versionable", $path));
     }
     $node = $this->session->getNode($path);
     $mixin = $metadata->versionable === 'simple' ? 'mix:simpleVersionable' : 'mix:versionable';
     if (!$node->isNodeType($mixin)) {
         $node->addMixin($mixin);
     }
     return $path;
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:14,代码来源:UnitOfWork.php

示例8: findOneBy

 protected function findOneBy($class, Request $request, $options)
 {
     if (!$options['mapping']) {
         $keys = $request->attributes->keys();
         $options['mapping'] = $keys ? array_combine($keys, $keys) : array();
     }
     foreach ($options['exclude'] as $exclude) {
         unset($options['mapping'][$exclude]);
     }
     if (!$options['mapping']) {
         return false;
     }
     $criteria = array();
     $metadata = $this->manager->getClassMetadata($class);
     foreach ($options['mapping'] as $attribute => $field) {
         if ($metadata->hasField($field) || $metadata->hasAssociation($field) && $metadata->isSingleValuedAssociation($field)) {
             $criteria[$field] = $request->attributes->get($attribute);
         }
     }
     if (!$criteria) {
         return false;
     }
     return $this->manager->getRepository($class)->findOneBy($criteria);
 }
开发者ID:Cohros,项目名称:KnowledgeBase,代码行数:24,代码来源:PHPCRParamConverter.php

示例9: testInvalidId

 /**
  * @dataProvider invalidIdProvider
  *
  * @expectedException \Doctrine\ODM\PHPCR\Mapping\MappingException
  *
  * @param string $class fqn of a class with invalid mapping
  */
 public function testInvalidId($class)
 {
     $this->dm->getClassMetadata($class);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:11,代码来源:AnnotationMappingTest.php


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