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