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