|
@@ 2085-2118 (lines=34) @@
|
| 2082 |
|
* |
| 2083 |
|
* @return void |
| 2084 |
|
*/ |
| 2085 |
|
private function cascadeRefresh($entity, array &$visited) |
| 2086 |
|
{ |
| 2087 |
|
$class = $this->em->getClassMetadata(get_class($entity)); |
| 2088 |
|
|
| 2089 |
|
$associationMappings = array_filter( |
| 2090 |
|
$class->associationMappings, |
| 2091 |
|
function ($assoc) { return $assoc['isCascadeRefresh']; } |
| 2092 |
|
); |
| 2093 |
|
|
| 2094 |
|
foreach ($associationMappings as $assoc) { |
| 2095 |
|
$relatedEntities = $class->reflFields[$assoc['fieldName']]->getValue($entity); |
| 2096 |
|
|
| 2097 |
|
switch (true) { |
| 2098 |
|
case ($relatedEntities instanceof PersistentCollection): |
| 2099 |
|
// Unwrap so that foreach() does not initialize |
| 2100 |
|
$relatedEntities = $relatedEntities->unwrap(); |
| 2101 |
|
// break; is commented intentionally! |
| 2102 |
|
|
| 2103 |
|
case ($relatedEntities instanceof Collection): |
| 2104 |
|
case (is_array($relatedEntities)): |
| 2105 |
|
foreach ($relatedEntities as $relatedEntity) { |
| 2106 |
|
$this->doRefresh($relatedEntity, $visited); |
| 2107 |
|
} |
| 2108 |
|
break; |
| 2109 |
|
|
| 2110 |
|
case ($relatedEntities !== null): |
| 2111 |
|
$this->doRefresh($relatedEntities, $visited); |
| 2112 |
|
break; |
| 2113 |
|
|
| 2114 |
|
default: |
| 2115 |
|
// Do nothing |
| 2116 |
|
} |
| 2117 |
|
} |
| 2118 |
|
} |
| 2119 |
|
|
| 2120 |
|
/** |
| 2121 |
|
* Cascades a detach operation to associated entities. |
|
@@ 2128-2161 (lines=34) @@
|
| 2125 |
|
* |
| 2126 |
|
* @return void |
| 2127 |
|
*/ |
| 2128 |
|
private function cascadeDetach($entity, array &$visited) |
| 2129 |
|
{ |
| 2130 |
|
$class = $this->em->getClassMetadata(get_class($entity)); |
| 2131 |
|
|
| 2132 |
|
$associationMappings = array_filter( |
| 2133 |
|
$class->associationMappings, |
| 2134 |
|
function ($assoc) { return $assoc['isCascadeDetach']; } |
| 2135 |
|
); |
| 2136 |
|
|
| 2137 |
|
foreach ($associationMappings as $assoc) { |
| 2138 |
|
$relatedEntities = $class->reflFields[$assoc['fieldName']]->getValue($entity); |
| 2139 |
|
|
| 2140 |
|
switch (true) { |
| 2141 |
|
case ($relatedEntities instanceof PersistentCollection): |
| 2142 |
|
// Unwrap so that foreach() does not initialize |
| 2143 |
|
$relatedEntities = $relatedEntities->unwrap(); |
| 2144 |
|
// break; is commented intentionally! |
| 2145 |
|
|
| 2146 |
|
case ($relatedEntities instanceof Collection): |
| 2147 |
|
case (is_array($relatedEntities)): |
| 2148 |
|
foreach ($relatedEntities as $relatedEntity) { |
| 2149 |
|
$this->doDetach($relatedEntity, $visited); |
| 2150 |
|
} |
| 2151 |
|
break; |
| 2152 |
|
|
| 2153 |
|
case ($relatedEntities !== null): |
| 2154 |
|
$this->doDetach($relatedEntities, $visited); |
| 2155 |
|
break; |
| 2156 |
|
|
| 2157 |
|
default: |
| 2158 |
|
// Do nothing |
| 2159 |
|
} |
| 2160 |
|
} |
| 2161 |
|
} |
| 2162 |
|
|
| 2163 |
|
/** |
| 2164 |
|
* Cascades a merge operation to associated entities. |