/** * {@inheritdoc} */ public function saveAll(array $objects, array $options = []) { if (empty($objects)) { return; } $allOptions = $this->optionsResolver->resolveSaveAllOptions($options); $itemOptions = $allOptions; $itemOptions['flush'] = false; foreach ($objects as $object) { $this->save($object, $itemOptions); } if (true === $allOptions['flush']) { $this->objectManager->flush(); } }
/** * {@inheritdoc} */ public function saveAll(array $attributes, array $options = []) { if (empty($attributes)) { return; } $this->eventDispatcher->dispatch(AttributeEvents::PRE_SAVE_ALL, new GenericEvent($attributes)); $allOptions = $this->optionsResolver->resolveSaveAllOptions($options); $itemOptions = $allOptions; $itemOptions['flush'] = false; foreach ($attributes as $attribute) { $this->save($attribute, $itemOptions); } if (true === $allOptions['flush']) { $this->objectManager->flush(); } $this->eventDispatcher->dispatch(AttributeEvents::POST_SAVE_ALL, new GenericEvent($attributes)); }
/** * {@inheritdoc} */ public function saveAll(array $products, array $options = []) { if (empty($products)) { return; } $options = $this->optionsResolver->resolveSaveAllOptions($options); $this->eventDispatcher->dispatch(StorageEvents::PRE_SAVE_ALL, new GenericEvent($products, $options)); $itemOptions = $options; $itemOptions['flush'] = false; foreach ($products as $product) { $this->save($product, $itemOptions); } if (true === $options['flush']) { $this->objectManager->flush(); } $this->eventDispatcher->dispatch(StorageEvents::POST_SAVE_ALL, new GenericEvent($products, $options)); }
/** * {@inheritdoc} */ public function saveAll(array $groups, array $options = []) { if (empty($groups)) { return; } $this->eventDispatcher->dispatch(StorageEvents::PRE_SAVE_ALL, new GenericEvent($groups)); $options = $this->optionsResolver->resolveSaveAllOptions($options); foreach ($groups as $group) { $this->validateGroup($group); $this->eventDispatcher->dispatch(StorageEvents::PRE_SAVE, new GenericEvent($group, $options)); $this->persistGroup($group, $options); } $this->objectManager->flush(); foreach ($groups as $group) { $this->eventDispatcher->dispatch(StorageEvents::POST_SAVE, new GenericEvent($group, $options)); } $this->eventDispatcher->dispatch(StorageEvents::POST_SAVE_ALL, new GenericEvent($groups, $options)); }