本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadata::isSingleValuedAssociation方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadata::isSingleValuedAssociation方法的具体用法?PHP ClassMetadata::isSingleValuedAssociation怎么用?PHP ClassMetadata::isSingleValuedAssociation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Mapping\ClassMetadata
的用法示例。
在下文中一共展示了ClassMetadata::isSingleValuedAssociation方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isIgnoredRelation
/**
* {@inheritdoc}
*/
protected function isIgnoredRelation(ClassMetadata $metadata, $associationName)
{
// skip workflow and collection relations
if ($this->isWorkflowField($associationName) || !$metadata->isSingleValuedAssociation($associationName)) {
return true;
}
return parent::isIgnoredRelation($metadata, $associationName);
}
示例2: findParentMapping
/**
* Find the parent object's property which holds the collection entries
*
* @param object $parent The parent entity.
* @param ClassMetadata $metaData Metadata of the object that is being created.
*
* @return string|boolean The name of the parent mapping field or false if none is found.
*/
protected function findParentMapping($parent, ClassMetadata $metaData)
{
$parentClass = ClassUtils::getClass($parent);
foreach ($metaData->associationMappings as $mapping) {
if ($mapping['targetEntity'] == $parentClass && $metaData->isSingleValuedAssociation($mapping['fieldName'])) {
return $mapping['fieldName'];
}
}
return false;
}
示例3: isIgnoredRelation
/**
* {@inheritdoc}
*/
public function isIgnoredRelation(ClassMetadata $metadata, $associationName)
{
if ($metadata->isSingleValuedAssociation($associationName)) {
$targetClassName = $metadata->getAssociationTargetClass($associationName);
$groups = $this->groupingConfigProvider->getConfig($targetClassName)->get('groups');
if (!empty($groups) && in_array(GroupingScope::GROUP_DICTIONARY, $groups)) {
return true;
}
}
return false;
}
示例4: getAssociationValue
/** {@inheritdoc} */
public function getAssociationValue($object, $fieldName)
{
if (!$this->hasAssociation($fieldName)) {
throw new MetadataException("Association '{$fieldName}' not found in class '{$this->getClass()}'.");
}
if ($this->classMetadata->isSingleValuedAssociation($fieldName)) {
$value = $this->classMetadata->getFieldValue($object, $fieldName);
} else {
$value = $this->getCollection($object, $fieldName);
}
return $value;
}
示例5: getRelation
/**
* @param ClassMetadata $meta
* @param object $entity
* @param string $field
* @return bool|object
*/
private function getRelation(ClassMetadata $meta, $entity, $field)
{
if (!$meta->hasAssociation($field) || !$meta->isSingleValuedAssociation($field)) {
return FALSE;
}
// todo: allow access using property or method
$relation = $meta->getFieldValue($entity, $field);
if ($relation instanceof Collection) {
return FALSE;
}
if ($relation === NULL) {
$class = $meta->getAssociationTargetClass($field);
$relationMeta = $this->mapper->getEntityManager()->getClassMetadata($class);
$relation = $relationMeta->newInstance();
$meta->setFieldValue($entity, $field, $relation);
}
return $relation;
}
示例6: convertMetadata
/**
* @param ClassMetadata $metadata
* @return JavaScript\Metadata
*/
private function convertMetadata(ClassMetadata $metadata)
{
$meta = new JavaScript\Metadata();
$meta->originalName = $metadata->getName();
$meta->namespace = str_replace('\\', '_', $metadata->getReflectionClass()->getNamespaceName());
$meta->functionName = $metadata->getReflectionClass()->getShortName();
$parent = $metadata->getReflectionClass()->getParentClass();
$meta->superFunctionName = $parent ? $parent->getShortName() : 'DBEntity';
// Convert fields.
foreach ($metadata->getFieldNames() as $fieldName) {
$field = new JavaScript\Field();
$field->name = $fieldName;
$field->methodName = ucfirst($fieldName);
$field->type = $this->convertDoctrineType($metadata->getTypeOfField($fieldName));
$field->isIdentifier = $metadata->isIdentifier($fieldName);
$meta->fields[] = $field;
}
// Convert associations.
foreach ($metadata->getAssociationNames() as $assocName) {
$assoc = new JavaScript\Association();
$assoc->name = $assocName;
$assoc->methodName = ucfirst($assocName);
$assoc->isCollection = $metadata->isCollectionValuedAssociation($assocName);
$assoc->isSingle = $metadata->isSingleValuedAssociation($assocName);
$assoc->singleName = Inflector::singularize($assoc->methodName);
$assoc->invertedField = $metadata->getAssociationMappedByTargetField($assocName);
$targetClass = new \ReflectionClass($metadata->getAssociationTargetClass($assocName));
$assoc->singleType = $targetClass->getShortName();
$assoc->type = $assoc->singleType . ($assoc->isCollection ? '[]' : '');
$meta->associations[] = $assoc;
}
return $meta;
}
示例7: mapValue
/**
* @param ClassMetadata $objectMeta
* @param string $field
* @param mixed $value
*/
protected function mapValue($om, ClassMetadata $objectMeta, $field, &$value)
{
if (!$objectMeta->isSingleValuedAssociation($field)) {
return;
}
$mapping = $objectMeta->getAssociationMapping($field);
$value = $value ? $om->getReference($mapping['targetEntity'], $value) : null;
}
示例8: decodeAssociation
/**
* @param ClassMetadata $metaData
* @param object $entity
* @param string $key
* @param mixed $value
*/
private function decodeAssociation($metaData, $entity, $key, $value)
{
if ($metaData->isSingleValuedAssociation($key)) {
$this->decodeAssociationSingle($metaData, $entity, $key, $value);
} else {
//multiple
$this->decodeAssociationMulti($metaData, $entity, $key, $value);
}
}
示例9: buildSelectForUpdateQuery
/**
* @param EntityRepository $repository
* @param ORMMetadata $class
* @return \Doctrine\ORM\QueryBuilder
*/
protected function buildSelectForUpdateQuery(EntityRepository $repository, ORMMetadata $class)
{
$qb = $repository->createQueryBuilder('e', 'e.id');
$i = 0;
foreach ($class->getAssociationMappings() as $assocMapping) {
if (!$class->isSingleValuedAssociation($assocMapping['fieldName'])) {
continue;
}
$targetClass = $this->entityManager->getClassMetadata($assocMapping['targetEntity']);
$alias = substr($assocMapping['fieldName'], 0, 1) . $i++;
$qb->leftJoin('e.' . $assocMapping['fieldName'], $alias)->addSelect($alias);
// todo: deeper!
}
return $qb;
}
示例10: getCollection
/**
* @param ClassMetadata $meta
* @param object $entity
* @param string $field
* @return Collection
*/
private function getCollection(ClassMetadata $meta, $entity, $field)
{
if (!$meta->hasAssociation($field) || $meta->isSingleValuedAssociation($field)) {
return FALSE;
}
$collection = $meta->getFieldValue($entity, $field);
if ($collection === NULL) {
$collection = new ArrayCollection();
$meta->setFieldValue($entity, $field, $collection);
}
return $collection;
}
示例11: mapValue
/**
* Maps ids of associations to references
*
* @param ClassMetadata $class
* @param string $field
* @param mixed $value
*/
protected function mapValue(ClassMetadata $class, $field, &$value)
{
if (!$class->isSingleValuedAssociation($field)) {
return;
}
$mapping = $class->getAssociationMapping($field);
$value = $value ? $this->em->getReference($mapping['targetEntity'], $value) : null;
}