本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadata::getAssociationMapping方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::getAssociationMapping方法的具体用法?PHP ClassMetadata::getAssociationMapping怎么用?PHP ClassMetadata::getAssociationMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Mapping\ClassMetadata
的用法示例。
在下文中一共展示了ClassMetadata::getAssociationMapping方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAssociationMapping
/** {@inheritdoc} */
public function getAssociationMapping($name)
{
if (!$this->classMetadata->hasAssociation($name)) {
throw new MetadataException("Association '{$name}' not found in class '{$this->getClass()}'.");
}
return $this->classMetadata->getAssociationMapping($name);
}
示例2: test_custom_region_gets_set_on_the_meta_data_on_build
public function test_custom_region_gets_set_on_the_meta_data_on_build()
{
$cache = $this->factory('READ_ONLY', 'custom_region');
$cache->build();
$mapping = $this->metadata->getAssociationMapping($this->field);
$this->assertEquals('custom_region', $mapping['cache']['region']);
}
示例3: testClassMetadataInstanceSerialization
public function testClassMetadataInstanceSerialization()
{
$cm = new ClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
// Test initial state
$this->assertTrue(count($cm->getReflectionProperties()) == 0);
$this->assertTrue($cm->reflClass instanceof \ReflectionClass);
$this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->name);
$this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->rootEntityName);
$this->assertEquals(array(), $cm->subClasses);
$this->assertEquals(array(), $cm->parentClasses);
// Customize state
$cm->setSubclasses(array("One", "Two", "Three"));
$cm->setParentClasses(array("UserParent"));
$cm->setCustomRepositoryClass("UserRepository");
$cm->setDiscriminatorColumn(array('name' => 'disc', 'type' => 'integer'));
$cm->mapOneToOne(array('fieldName' => 'phonenumbers', 'targetEntity' => 'Bar', 'mappedBy' => 'foo'));
$this->assertTrue($cm->getAssociationMapping('phonenumbers') instanceof \Doctrine\ORM\Mapping\OneToOneMapping);
$this->assertEquals(1, count($cm->associationMappings));
$serialized = serialize($cm);
$cm = unserialize($serialized);
// Check state
$this->assertTrue(count($cm->getReflectionProperties()) > 0);
$this->assertTrue($cm->reflClass instanceof \ReflectionClass);
$this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->name);
$this->assertEquals('UserParent', $cm->rootEntityName);
$this->assertEquals(array('One', 'Two', 'Three'), $cm->subClasses);
$this->assertEquals(array('UserParent'), $cm->parentClasses);
$this->assertEquals('UserRepository', $cm->getCustomRepositoryClass());
$this->assertEquals(array('name' => 'disc', 'type' => 'integer'), $cm->discriminatorColumn);
$this->assertTrue($cm->getAssociationMapping('phonenumbers') instanceof \Doctrine\ORM\Mapping\OneToOneMapping);
$this->assertEquals(1, count($cm->associationMappings));
$oneOneMapping = $cm->getAssociationMapping('phonenumbers');
$this->assertEquals('phonenumbers', $oneOneMapping->getSourceFieldName());
$this->assertEquals('Doctrine\\Tests\\Models\\CMS\\Bar', $oneOneMapping->getTargetEntityName());
}
示例4: getAssociationMapping
/**
* @param string $association
* @return array
* @throws InvalidAssociationException
*/
protected function getAssociationMapping($association)
{
try {
return $this->metadata->getAssociationMapping($association);
} catch (MappingException $e) {
throw InvalidAssociationException::associationNotExist($this->entity, $association, $e);
}
}
示例5: isIgnoredRelation
/**
* {@inheritdoc}
*/
public function isIgnoredRelation(ClassMetadata $metadata, $associationName)
{
$mapping = $metadata->getAssociationMapping($associationName);
if (!$mapping['isOwningSide'] || !($mapping['type'] & ClassMetadata::TO_ONE)) {
return false;
}
return $associationName === 'workflowItem' || $associationName === 'workflowStep';
}
示例6: getForeignPropertyMeta
/**
* Gibt das Property für eine Objekt-Fremd-Beziehung zurück
*
* dies ist z.B. bei der ManyToOne Seite möglich
* @return Psc\CMS\EntityPropertyMeta
*/
public function getForeignPropertyMeta(EntityMeta $foreignEntity)
{
throw new \Psc\Code\NotImplementedException();
$foreignField = \Psc\Inflector::create()->propertyName($foreignEntity->getGClass()->getClassName());
//var_dump($foreignEntity->getClassMetadata()->associationMappings);
//var_dump($this->classMetadata->associationMappings);
//var_dump($this->classMetadata->getFieldForColumn($foreignField));
$mapping = $this->classMetadata->getAssociationMapping();
//var_dump($mapping);
return $this->getPropertyMeta($mapping);
}
示例7: isIgnoredRelation
/**
* {@inheritdoc}
*/
public function isIgnoredRelation(ClassMetadata $metadata, $associationName)
{
if ($metadata->name !== 'Oro\\Bundle\\AttachmentBundle\\Entity\\Attachment') {
return false;
}
$mapping = $metadata->getAssociationMapping($associationName);
if (!$mapping['isOwningSide'] || !($mapping['type'] & ClassMetadata::MANY_TO_ONE)) {
return false;
}
return $associationName === ExtendHelper::buildAssociationName($mapping['targetEntity']);
}
示例8: getAssociationMapping
public static function getAssociationMapping(ClassMetadata $classMetadata, $name, $type = NULL)
{
if (!$classMetadata->hasAssociation($name)) {
return NULL;
}
$mapping = $classMetadata->getAssociationMapping($name);
$type = $type ? (array) $type : NULL;
if ($type === NULL || in_array($mapping['type'], $type, TRUE)) {
return $mapping;
}
return NULL;
}
示例9: isIgnoredRelation
/**
* {@inheritdoc}
*/
public function isIgnoredRelation(ClassMetadata $metadata, $associationName)
{
if ($metadata->name !== 'Oro\\Bundle\\TrackingBundle\\Entity\\TrackingVisit') {
return false;
}
$mapping = $metadata->getAssociationMapping($associationName);
if (!$mapping['isOwningSide'] || !($mapping['type'] & ClassMetadata::MANY_TO_ONE)) {
return false;
}
$identifierEventAssociationName = ExtendHelper::buildAssociationName($mapping['targetEntity'], IdentifierEventExtension::ASSOCIATION_KIND);
return $associationName === $identifierEventAssociationName;
}
示例10: isIgnoredRelation
/**
* {@inheritdoc}
*/
public function isIgnoredRelation(ClassMetadata $metadata, $associationName)
{
if (!$this->configManager->hasConfig($metadata->name, $associationName)) {
return false;
}
$groups = $this->configManager->getEntityConfig('grouping', $metadata->name)->get('groups');
if (empty($groups) || !in_array(ActivityScope::GROUP_ACTIVITY, $groups, true)) {
return false;
}
$mapping = $metadata->getAssociationMapping($associationName);
if (!$mapping['isOwningSide'] || !($mapping['type'] & ClassMetadata::MANY_TO_MANY)) {
return false;
}
$activityAssociationName = ExtendHelper::buildAssociationName($mapping['targetEntity'], ActivityScope::ASSOCIATION_KIND);
return $associationName === $activityAssociationName;
}
示例11: extendLoadMetadataForClass
/**
* Merge DoctrineClassMetadata and DataAuditClassMetadata
* @param DoctrineClassMetadata $doctrineClassMetadata
* @return null|ClassMetadata
* @throws \InvalidArgumentException
*/
public function extendLoadMetadataForClass(DoctrineClassMetadata $doctrineClassMetadata)
{
if ($doctrineClassMetadata->isMappedSuperclass || !($classMetadata = $this->loadMetadataForClass($doctrineClassMetadata->getReflectionClass()))) {
return null;
}
/** @var $property PropertyMetadata */
foreach ($classMetadata->propertyMetadata as $name => $property) {
if ($doctrineClassMetadata->isInheritedField($name) || isset($doctrineClassMetadata->associationMappings[$property->name]['inherited'])) {
unset($classMetadata->propertyMetadata[$name]);
continue;
}
if ($doctrineClassMetadata->isCollectionValuedAssociation($name)) {
$property->isCollection = true;
$targetMapping = $doctrineClassMetadata->getAssociationMapping($name);
if (!method_exists($targetMapping['targetEntity'], $property->method)) {
throw new \InvalidArgumentException(sprintf("Method %s in Class %s is not defined. Class must implement " . "a method '__toString' or configure getMethod with Versioned annotation", $property->method, $targetMapping['targetEntity']));
}
}
}
return $classMetadata;
}
示例12: getAssociationMetadata
private function getAssociationMetadata(ClassMetadata $meta, $associationName)
{
if (!$meta->hasAssociation($associationName)) {
return FALSE;
}
$association = $meta->getAssociationMapping($associationName);
if (!$association & ClassMetadata::TO_ONE) {
return FALSE;
}
return $association;
}
示例13: createAssociationField
/**
* @param FormBuilder $form
* @param ClassMetadata $metaData
* @param string $fieldName
*/
public function createAssociationField($form, $metaData, $fieldName)
{
$formField = new SelectField(array());
$formField->setLabel($this->translateName($fieldName));
$formField->setName($fieldName);
$mapping = $metaData->getAssociationMapping($fieldName);
$required = false;
$targetEntityName = $metaData->getAssociationTargetClass($fieldName);
$targetEntity = $this->doctrineService->getRepository($targetEntityName);
if ($metaData->isCollectionValuedAssociation($fieldName)) {
$formField->setMultiple(true);
$formField->setRequired(false);
} else {
foreach ($mapping['joinColumns'] as $joinColumn) {
if (!$joinColumn['nullable']) {
$required = true;
break;
}
}
$formField->setRequired($required);
}
$collection = static::entityToCollection($targetEntity->findAll(), !$formField->isMultiple());
$formField->setCollection($collection);
$form->addField($formField);
}
示例14: addDoctrineAssociations
/**
* @param EntityMetadata $entityMetadata
* @param ClassMetadata $classMetadata
*/
protected function addDoctrineAssociations(EntityMetadata $entityMetadata, ClassMetadata $classMetadata)
{
$associations = array_diff($classMetadata->getAssociationNames(), $this->getDeletedFields($classMetadata->name));
foreach ($associations as $fieldName) {
$fieldMetadata = $this->metadataFactory->createFieldMetadata(['field_name' => $fieldName], $classMetadata->getAssociationMapping($fieldName));
$entityMetadata->addFieldMetadata($fieldMetadata);
}
}
示例15: getFromClause
private function getFromClause(ClassMetadata $metadataActivity, ClassMetadata $metadataPerson)
{
$associationMapping = $metadataActivity->getAssociationMapping('person');
return $metadataActivity->getTableName() . ' JOIN ' . $metadataPerson->getTableName() . ' ON ' . $metadataPerson->getTableName() . '.' . $associationMapping['joinColumns'][0]['referencedColumnName'] . ' = ' . $associationMapping['joinColumns'][0]['name'];
}