|
@@ 1128-1151 (lines=24) @@
|
| 1125 |
|
* @param array $documents Array of documents to insert |
| 1126 |
|
* @param array $options Array of options to be used with batchInsert() |
| 1127 |
|
*/ |
| 1128 |
|
private function executeInserts(ClassMetadata $class, array $documents, array $options = array()) |
| 1129 |
|
{ |
| 1130 |
|
$persister = $this->getDocumentPersister($class->name); |
| 1131 |
|
|
| 1132 |
|
foreach ($documents as $oid => $document) { |
| 1133 |
|
$persister->addInsert($document); |
| 1134 |
|
unset($this->documentInsertions[$oid]); |
| 1135 |
|
} |
| 1136 |
|
|
| 1137 |
|
$persister->executeInserts($options); |
| 1138 |
|
|
| 1139 |
|
$hasPostPersistLifecycleCallbacks = ! empty($class->lifecycleCallbacks[Events::postPersist]); |
| 1140 |
|
$hasPostPersistListeners = $this->evm->hasListeners(Events::postPersist); |
| 1141 |
|
|
| 1142 |
|
foreach ($documents as $document) { |
| 1143 |
|
if ($hasPostPersistLifecycleCallbacks) { |
| 1144 |
|
$class->invokeLifecycleCallbacks(Events::postPersist, $document); |
| 1145 |
|
} |
| 1146 |
|
if ($hasPostPersistListeners) { |
| 1147 |
|
$this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($document, $this->dm)); |
| 1148 |
|
} |
| 1149 |
|
$this->cascadePostPersist($class, $document); |
| 1150 |
|
} |
| 1151 |
|
} |
| 1152 |
|
|
| 1153 |
|
/** |
| 1154 |
|
* Executes all document upserts for documents of the specified type. |
|
@@ 1160-1184 (lines=25) @@
|
| 1157 |
|
* @param array $documents Array of documents to upsert |
| 1158 |
|
* @param array $options Array of options to be used with batchInsert() |
| 1159 |
|
*/ |
| 1160 |
|
private function executeUpserts(ClassMetadata $class, array $documents, array $options = array()) |
| 1161 |
|
{ |
| 1162 |
|
$persister = $this->getDocumentPersister($class->name); |
| 1163 |
|
|
| 1164 |
|
|
| 1165 |
|
foreach ($documents as $oid => $document) { |
| 1166 |
|
$persister->addUpsert($document); |
| 1167 |
|
unset($this->documentUpserts[$oid]); |
| 1168 |
|
} |
| 1169 |
|
|
| 1170 |
|
$persister->executeUpserts($options); |
| 1171 |
|
|
| 1172 |
|
$hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postPersist]); |
| 1173 |
|
$hasListeners = $this->evm->hasListeners(Events::postPersist); |
| 1174 |
|
|
| 1175 |
|
foreach ($documents as $document) { |
| 1176 |
|
if ($hasLifecycleCallbacks) { |
| 1177 |
|
$class->invokeLifecycleCallbacks(Events::postPersist, $document); |
| 1178 |
|
} |
| 1179 |
|
if ($hasListeners) { |
| 1180 |
|
$this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($document, $this->dm)); |
| 1181 |
|
} |
| 1182 |
|
$this->cascadePostPersist($class, $document); |
| 1183 |
|
} |
| 1184 |
|
} |
| 1185 |
|
|
| 1186 |
|
/** |
| 1187 |
|
* Executes all document updates for documents of the specified type. |