Commit 7ec25f19 authored by romanb's avatar romanb

[2.0] Added missing recognition of the 'fetch' attribute in metadata drivers.

parent f731a083
......@@ -72,7 +72,7 @@ abstract class AssociationMapping
*
* @var integer
*/
public $fetchMode = self::FETCH_LAZY;
public $fetchMode;
/**
* Flag that indicates whether the class that defines this mapping is
......@@ -182,6 +182,8 @@ abstract class AssociationMapping
// Optional attributes for both sides
$this->isOptional = isset($mapping['optional']) ?
(bool)$mapping['optional'] : true;
$this->fetchMode = isset($mapping['fetch']) ?
$mapping['fetch'] : self::FETCH_LAZY;
$this->cascades = isset($mapping['cascade']) ?
(array)$mapping['cascade'] : array();
$this->isCascadeRemove = in_array('remove', $this->cascades);
......
......@@ -224,17 +224,20 @@ class AnnotationDriver implements Driver
$mapping['mappedBy'] = $oneToOneAnnot->mappedBy;
$mapping['cascade'] = $oneToOneAnnot->cascade;
$mapping['orphanRemoval'] = $oneToOneAnnot->orphanRemoval;
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $oneToOneAnnot->fetch);
$metadata->mapOneToOne($mapping);
} else if ($oneToManyAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\OneToMany')) {
$mapping['mappedBy'] = $oneToManyAnnot->mappedBy;
$mapping['targetEntity'] = $oneToManyAnnot->targetEntity;
$mapping['cascade'] = $oneToManyAnnot->cascade;
$mapping['orphanRemoval'] = $oneToManyAnnot->orphanRemoval;
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $oneToManyAnnot->fetch);
$metadata->mapOneToMany($mapping);
} else if ($manyToOneAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\ManyToOne')) {
$mapping['joinColumns'] = $joinColumns;
$mapping['cascade'] = $manyToOneAnnot->cascade;
$mapping['targetEntity'] = $manyToOneAnnot->targetEntity;
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $manyToOneAnnot->fetch);
$metadata->mapManyToOne($mapping);
} else if ($manyToManyAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\ManyToMany')) {
$joinTable = array();
......@@ -272,6 +275,7 @@ class AnnotationDriver implements Driver
$mapping['targetEntity'] = $manyToManyAnnot->targetEntity;
$mapping['mappedBy'] = $manyToManyAnnot->mappedBy;
$mapping['cascade'] = $manyToManyAnnot->cascade;
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $manyToManyAnnot->fetch);
$metadata->mapManyToMany($mapping);
}
}
......
......@@ -68,7 +68,7 @@ final class OneToOne extends Annotation {
public $targetEntity;
public $mappedBy;
public $cascade;
public $fetch;
public $fetch = 'LAZY';
public $optional;
public $orphanRemoval = false;
}
......@@ -76,20 +76,20 @@ final class OneToMany extends Annotation {
public $mappedBy;
public $targetEntity;
public $cascade;
public $fetch;
public $fetch = 'LAZY';
public $orphanRemoval = false;
}
final class ManyToOne extends Annotation {
public $targetEntity;
public $cascade;
public $fetch;
public $fetch = 'LAZY';
public $optional;
}
final class ManyToMany extends Annotation {
public $targetEntity;
public $mappedBy;
public $cascade;
public $fetch;
public $fetch = 'LAZY';
}
final class ElementCollection extends Annotation {
public $tableName;
......
......@@ -195,9 +195,13 @@ class XmlDriver extends AbstractFileDriver
foreach ($xmlRoot->{'one-to-one'} as $oneToOneElement) {
$mapping = array(
'fieldName' => (string)$oneToOneElement['field'],
'targetEntity' => (string)$oneToOneElement['target-entity'],
'targetEntity' => (string)$oneToOneElement['target-entity']
);
if (isset($oneToOneElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . (string)$oneToOneElement['fetch']);
}
if (isset($oneToOneElement['mapped-by'])) {
$mapping['mappedBy'] = (string)$oneToOneElement['mapped-by'];
} else {
......@@ -237,6 +241,10 @@ class XmlDriver extends AbstractFileDriver
'mappedBy' => (string)$oneToManyElement['mapped-by']
);
if (isset($oneToManyElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . (string)$oneToManyElement['fetch']);
}
if (isset($oneToManyElement->cascade)) {
$mapping['cascade'] = $this->_getCascadeMappings($oneToManyElement->cascade);
}
......@@ -257,6 +265,10 @@ class XmlDriver extends AbstractFileDriver
'targetEntity' => (string)$manyToOneElement['target-entity']
);
if (isset($manyToOneElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . (string)$manyToOneElement['fetch']);
}
$joinColumns = array();
if (isset($manyToOneElement->{'join-column'})) {
......@@ -295,6 +307,10 @@ class XmlDriver extends AbstractFileDriver
'targetEntity' => (string)$manyToManyElement['target-entity']
);
if (isset($manyToManyElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . (string)$manyToManyElement['fetch']);
}
if (isset($manyToManyElement['mappedBy'])) {
$mapping['mappedBy'] = (string)$manyToManyElement['mapped-by'];
} else if (isset($manyToManyElement->{'join-table'})) {
......
......@@ -208,6 +208,10 @@ class YamlDriver extends AbstractFileDriver
'targetEntity' => $oneToOneElement['targetEntity']
);
if (isset($oneToOneElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $oneToOneElement['fetch']);
}
if (isset($oneToOneElement['mappedBy'])) {
$mapping['mappedBy'] = $oneToOneElement['mappedBy'];
} else {
......@@ -247,6 +251,10 @@ class YamlDriver extends AbstractFileDriver
'mappedBy' => $oneToManyElement['mappedBy']
);
if (isset($oneToManyElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $oneToManyElement['fetch']);
}
if (isset($oneToManyElement['cascade'])) {
$mapping['cascade'] = $this->_getCascadeMappings($oneToManyElement['cascade']);
}
......@@ -263,6 +271,10 @@ class YamlDriver extends AbstractFileDriver
'targetEntity' => $manyToOneElement['targetEntity']
);
if (isset($manyToOneElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $manyToOneElement['fetch']);
}
$joinColumns = array();
if (isset($manyToOneElement['joinColumn'])) {
......@@ -297,6 +309,10 @@ class YamlDriver extends AbstractFileDriver
'targetEntity' => $manyToManyElement['targetEntity']
);
if (isset($manyToManyElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . $manyToManyElement['fetch']);
}
if (isset($manyToManyElement['mappedBy'])) {
$mapping['mappedBy'] = $manyToManyElement['mappedBy'];
} else if (isset($manyToManyElement['joinTable'])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment