[2.0] Simplification and fix to cascades.
This commit is contained in:
parent
08694d1826
commit
4918d3e174
@ -51,7 +51,6 @@ abstract class AssociationMapping
|
||||
*/
|
||||
const FETCH_EAGER = 3;
|
||||
|
||||
public $cascades = array();
|
||||
public $isCascadeRemove;
|
||||
public $isCascadePersist;
|
||||
public $isCascadeRefresh;
|
||||
@ -165,13 +164,12 @@ abstract class AssociationMapping
|
||||
// Optional attributes for both sides
|
||||
$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);
|
||||
$this->isCascadePersist = in_array('persist', $this->cascades);
|
||||
$this->isCascadeRefresh = in_array('refresh', $this->cascades);
|
||||
$this->isCascadeMerge = in_array('merge', $this->cascades);
|
||||
$this->isCascadeDetach = in_array('detach', $this->cascades);
|
||||
$cascades = isset($mapping['cascade']) ? $mapping['cascade'] : array();
|
||||
$this->isCascadeRemove = in_array('remove', $cascades);
|
||||
$this->isCascadePersist = in_array('persist', $cascades);
|
||||
$this->isCascadeRefresh = in_array('refresh', $cascades);
|
||||
$this->isCascadeMerge = in_array('merge', $cascades);
|
||||
$this->isCascadeDetach = in_array('detach', $cascades);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -360,6 +358,15 @@ abstract class AssociationMapping
|
||||
{
|
||||
return (bool) $this->joinTable;
|
||||
}
|
||||
|
||||
public function hasCascades()
|
||||
{
|
||||
return $this->isCascadePersist ||
|
||||
$this->isCascadeRemove ||
|
||||
$this->isCascadeRefresh ||
|
||||
$this->isCascadeMerge ||
|
||||
$this->isCascadeDetach;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads data in $target domain object using this association.
|
||||
|
@ -331,8 +331,14 @@ class AnnotationExporter extends AbstractExporter
|
||||
if (isset($associationMapping->mappedByFieldName)) {
|
||||
$typeOptions[] = 'mappedBy="' . $associationMapping->mappedByFieldName . '"';
|
||||
}
|
||||
if (isset($associationMapping->cascades) && $associationMapping->cascades) {
|
||||
$typeOptions[] = 'cascade={"' . implode('"', $associationMapping->cascades) . '"}';
|
||||
if ($associationMapping->hasCascades()) {
|
||||
$cascades = array();
|
||||
if ($this->isCascadePersist) $cascades[] = '"persist"';
|
||||
if ($this->isCascadeRemove) $cascades[] = '"remove"';
|
||||
if ($this->isCascadeDetach) $cascades[] = '"detach"';
|
||||
if ($this->isCascadeMerge) $cascades[] = '"merge"';
|
||||
if ($this->isCascadeRefresh) $cascades[] = '"refresh"';
|
||||
$typeOptions[] = 'cascade={' . implode(',', $cascades) . '}';
|
||||
}
|
||||
if (isset($associationMapping->orphanRemoval) && $associationMapping->orphanRemoval) {
|
||||
$typeOptions[] = 'orphanRemoval=' . ($associationMapping->orphanRemoval ? 'true' : 'false');
|
||||
|
Loading…
x
Reference in New Issue
Block a user