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