@@ 1147-1170 (lines=24) @@ | ||
1144 | * @param array $documents Array of documents to insert |
|
1145 | * @param array $options Array of options to be used with batchInsert() |
|
1146 | */ |
|
1147 | private function executeInserts(ClassMetadata $class, array $documents, array $options = array()) |
|
1148 | { |
|
1149 | $persister = $this->getDocumentPersister($class->name); |
|
1150 | ||
1151 | foreach ($documents as $oid => $document) { |
|
1152 | $persister->addInsert($document); |
|
1153 | unset($this->documentInsertions[$oid]); |
|
1154 | } |
|
1155 | ||
1156 | $persister->executeInserts($options); |
|
1157 | ||
1158 | $hasPostPersistLifecycleCallbacks = ! empty($class->lifecycleCallbacks[Events::postPersist]); |
|
1159 | $hasPostPersistListeners = $this->evm->hasListeners(Events::postPersist); |
|
1160 | ||
1161 | foreach ($documents as $document) { |
|
1162 | if ($hasPostPersistLifecycleCallbacks) { |
|
1163 | $class->invokeLifecycleCallbacks(Events::postPersist, $document); |
|
1164 | } |
|
1165 | if ($hasPostPersistListeners) { |
|
1166 | $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($document, $this->dm)); |
|
1167 | } |
|
1168 | $this->cascadePostPersist($class, $document); |
|
1169 | } |
|
1170 | } |
|
1171 | ||
1172 | /** |
|
1173 | * Executes all document upserts for documents of the specified type. |
|
@@ 1179-1203 (lines=25) @@ | ||
1176 | * @param array $documents Array of documents to upsert |
|
1177 | * @param array $options Array of options to be used with batchInsert() |
|
1178 | */ |
|
1179 | private function executeUpserts(ClassMetadata $class, array $documents, array $options = array()) |
|
1180 | { |
|
1181 | $persister = $this->getDocumentPersister($class->name); |
|
1182 | ||
1183 | ||
1184 | foreach ($documents as $oid => $document) { |
|
1185 | $persister->addUpsert($document); |
|
1186 | unset($this->documentUpserts[$oid]); |
|
1187 | } |
|
1188 | ||
1189 | $persister->executeUpserts($options); |
|
1190 | ||
1191 | $hasLifecycleCallbacks = isset($class->lifecycleCallbacks[Events::postPersist]); |
|
1192 | $hasListeners = $this->evm->hasListeners(Events::postPersist); |
|
1193 | ||
1194 | foreach ($documents as $document) { |
|
1195 | if ($hasLifecycleCallbacks) { |
|
1196 | $class->invokeLifecycleCallbacks(Events::postPersist, $document); |
|
1197 | } |
|
1198 | if ($hasListeners) { |
|
1199 | $this->evm->dispatchEvent(Events::postPersist, new LifecycleEventArgs($document, $this->dm)); |
|
1200 | } |
|
1201 | $this->cascadePostPersist($class, $document); |
|
1202 | } |
|
1203 | } |
|
1204 | ||
1205 | /** |
|
1206 | * Executes all document updates for documents of the specified type. |