本文整理汇总了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');
}
示例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;
}
示例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');
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}