|
@@ 2066-2099 (lines=34) @@
|
| 2063 |
|
* |
| 2064 |
|
* @return void |
| 2065 |
|
*/ |
| 2066 |
|
private function cascadeRefresh($entity, array &$visited) |
| 2067 |
|
{ |
| 2068 |
|
$class = $this->em->getClassMetadata(get_class($entity)); |
| 2069 |
|
|
| 2070 |
|
$associationMappings = array_filter( |
| 2071 |
|
$class->associationMappings, |
| 2072 |
|
function ($assoc) { return $assoc['isCascadeRefresh']; } |
| 2073 |
|
); |
| 2074 |
|
|
| 2075 |
|
foreach ($associationMappings as $assoc) { |
| 2076 |
|
$relatedEntities = $class->reflFields[$assoc['fieldName']]->getValue($entity); |
| 2077 |
|
|
| 2078 |
|
switch (true) { |
| 2079 |
|
case ($relatedEntities instanceof PersistentCollection): |
| 2080 |
|
// Unwrap so that foreach() does not initialize |
| 2081 |
|
$relatedEntities = $relatedEntities->unwrap(); |
| 2082 |
|
// break; is commented intentionally! |
| 2083 |
|
|
| 2084 |
|
case ($relatedEntities instanceof Collection): |
| 2085 |
|
case (is_array($relatedEntities)): |
| 2086 |
|
foreach ($relatedEntities as $relatedEntity) { |
| 2087 |
|
$this->doRefresh($relatedEntity, $visited); |
| 2088 |
|
} |
| 2089 |
|
break; |
| 2090 |
|
|
| 2091 |
|
case ($relatedEntities !== null): |
| 2092 |
|
$this->doRefresh($relatedEntities, $visited); |
| 2093 |
|
break; |
| 2094 |
|
|
| 2095 |
|
default: |
| 2096 |
|
// Do nothing |
| 2097 |
|
} |
| 2098 |
|
} |
| 2099 |
|
} |
| 2100 |
|
|
| 2101 |
|
/** |
| 2102 |
|
* Cascades a detach operation to associated entities. |
|
@@ 2109-2142 (lines=34) @@
|
| 2106 |
|
* |
| 2107 |
|
* @return void |
| 2108 |
|
*/ |
| 2109 |
|
private function cascadeDetach($entity, array &$visited) |
| 2110 |
|
{ |
| 2111 |
|
$class = $this->em->getClassMetadata(get_class($entity)); |
| 2112 |
|
|
| 2113 |
|
$associationMappings = array_filter( |
| 2114 |
|
$class->associationMappings, |
| 2115 |
|
function ($assoc) { return $assoc['isCascadeDetach']; } |
| 2116 |
|
); |
| 2117 |
|
|
| 2118 |
|
foreach ($associationMappings as $assoc) { |
| 2119 |
|
$relatedEntities = $class->reflFields[$assoc['fieldName']]->getValue($entity); |
| 2120 |
|
|
| 2121 |
|
switch (true) { |
| 2122 |
|
case ($relatedEntities instanceof PersistentCollection): |
| 2123 |
|
// Unwrap so that foreach() does not initialize |
| 2124 |
|
$relatedEntities = $relatedEntities->unwrap(); |
| 2125 |
|
// break; is commented intentionally! |
| 2126 |
|
|
| 2127 |
|
case ($relatedEntities instanceof Collection): |
| 2128 |
|
case (is_array($relatedEntities)): |
| 2129 |
|
foreach ($relatedEntities as $relatedEntity) { |
| 2130 |
|
$this->doDetach($relatedEntity, $visited); |
| 2131 |
|
} |
| 2132 |
|
break; |
| 2133 |
|
|
| 2134 |
|
case ($relatedEntities !== null): |
| 2135 |
|
$this->doDetach($relatedEntities, $visited); |
| 2136 |
|
break; |
| 2137 |
|
|
| 2138 |
|
default: |
| 2139 |
|
// Do nothing |
| 2140 |
|
} |
| 2141 |
|
} |
| 2142 |
|
} |
| 2143 |
|
|
| 2144 |
|
/** |
| 2145 |
|
* Cascades a merge operation to associated entities. |