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