/** * {@inheritdoc} */ public function save($group, array $options = []) { /* @var GroupInterface */ if (!$group instanceof GroupInterface) { throw new \InvalidArgumentException(sprintf('Expects a "Pim\\Bundle\\CatalogBundle\\Model\\GroupInterface", "%s" provided.', ClassUtils::getClass($group))); } $this->eventDispatcher->dispatch(GroupEvents::PRE_SAVE, new GenericEvent($group)); $options = $this->optionsResolver->resolveSaveOptions($options); $this->versionContext->addContextInfo(sprintf('Comes from variant group %s', $group->getCode()), $this->productClassName); if ($group->getType()->isVariant()) { $template = $group->getProductTemplate(); if (null !== $template) { $this->templateMediaManager->handleProductTemplateMedia($template); } } $this->objectManager->persist($group); if (true === $options['flush']) { $this->objectManager->flush(); } if (count($options['add_products']) > 0) { $this->addProducts($options['add_products']); } if (count($options['remove_products']) > 0) { $this->removeProducts($options['remove_products']); } if ($group->getType()->isVariant() && true === $options['copy_values_to_products']) { $this->copyVariantGroupValues($group); } $this->eventDispatcher->dispatch(GroupEvents::POST_SAVE, new GenericEvent($group)); }
/** * {@inheritdoc} */ public function save($group, array $options = []) { $this->validateGroup($group); $this->eventDispatcher->dispatch(StorageEvents::PRE_SAVE, new GenericEvent($group)); $options = $this->optionsResolver->resolveSaveOptions($options); $this->persistGroup($group, $options); $this->objectManager->flush(); $this->eventDispatcher->dispatch(StorageEvents::POST_SAVE, new GenericEvent($group)); }
/** * {@inheritdoc} */ public function save($attribute, array $options = []) { if (!$attribute instanceof AttributeInterface) { throw new \InvalidArgumentException(sprintf('Expects a "Pim\\Bundle\\CatalogBundle\\Model\\AttributeInterface", "%s" provided.', ClassUtils::getClass($attribute))); } $this->eventDispatcher->dispatch(AttributeEvents::PRE_SAVE, new GenericEvent($attribute)); $options = $this->optionsResolver->resolveSaveOptions($options); $this->objectManager->persist($attribute); if (true === $options['flush']) { $this->objectManager->flush(); } $this->eventDispatcher->dispatch(AttributeEvents::POST_SAVE, new GenericEvent($attribute)); }
/** * {@inheritdoc} */ public function save($object, array $options = []) { if (!$object instanceof $this->savedClass) { throw new \InvalidArgumentException(sprintf('Expects a "%s", "%s" provided.', $this->savedClass, ClassUtils::getClass($object))); } $options = $this->optionsResolver->resolveSaveOptions($options); $this->objectManager->persist($object); if (true === $options['flush'] && true === $options['flush_only_object']) { $this->objectManager->flush($object); } elseif (true === $options['flush']) { $this->objectManager->flush(); } }
/** * {@inheritdoc} */ public function save($object, array $options = []) { if (!$object instanceof $this->savedClass) { throw new \InvalidArgumentException(sprintf('Expects a "%s", "%s" provided.', $this->savedClass, ClassUtils::getClass($object))); } $this->eventDispatcher->dispatch(StorageEvents::PRE_SAVE, new GenericEvent($object, $options)); $options = $this->optionsResolver->resolveSaveOptions($options); $this->objectManager->persist($object); if (true === $options['flush']) { $this->objectManager->flush(); } $this->eventDispatcher->dispatch(StorageEvents::POST_SAVE, new GenericEvent($object, $options)); }
/** * {@inheritdoc} */ public function save($channel, array $options = []) { if (!$channel instanceof ChannelInterface) { throw new \InvalidArgumentException(sprintf('Expects a "Pim\\Bundle\\CatalogBundle\\Model\\ChannelInterface", "%s" provided.', get_class($channel))); } $this->eventDispatcher->dispatch(StorageEvents::PRE_SAVE, new GenericEvent($channel)); $options = $this->optionsResolver->resolveSaveOptions($options); $this->objectManager->persist($channel); if (true === $options['flush']) { $this->objectManager->flush(); } $this->eventDispatcher->dispatch(StorageEvents::POST_SAVE, new GenericEvent($channel)); }
/** * {@inheritdoc} */ public function save($channel, array $options = []) { if (!$channel instanceof ChannelInterface) { throw new \InvalidArgumentException(sprintf('Expects a "Pim\\Bundle\\CatalogBundle\\Model\\ChannelInterface", "%s" provided.', get_class($channel))); } $options = $this->optionsResolver->resolveSaveOptions($options); $this->objectManager->persist($channel); if (true === $options['schedule']) { $this->completenessManager->scheduleForChannel($channel); } if (true === $options['flush']) { $this->objectManager->flush(); } }
/** * {@inheritdoc} */ public function save($family, array $options = []) { if (!$family instanceof FamilyInterface) { throw new \InvalidArgumentException(sprintf('Expects a "Pim\\Bundle\\CatalogBundle\\Model\\FamilyInterface", "%s" provided.', ClassUtils::getClass($family))); } $options = $this->optionsResolver->resolveSaveOptions($options); $this->objectManager->persist($family); if (true === $options['flush']) { $this->objectManager->flush(); } if (true === $options['schedule']) { $this->completenessManager->scheduleForFamily($family); } }
/** * {@inheritdoc} */ public function save($family, array $options = []) { if (!$family instanceof FamilyInterface) { throw new \InvalidArgumentException(sprintf('Expects a "Pim\\Component\\Catalog\\Model\\FamilyInterface", "%s" provided.', ClassUtils::getClass($family))); } $this->eventDispatcher->dispatch(StorageEvents::PRE_SAVE, new GenericEvent($family)); $options = $this->optionsResolver->resolveSaveOptions($options); $this->objectManager->persist($family); if (true === $options['flush']) { $this->objectManager->flush(); } if (true === $options['schedule']) { $this->completenessManager->scheduleForFamily($family); } $this->eventDispatcher->dispatch(StorageEvents::POST_SAVE, new GenericEvent($family)); }
/** * {@inheritdoc} */ public function save($product, array $options = []) { if (!$product instanceof ProductInterface) { throw new \InvalidArgumentException(sprintf('Expects a Pim\\Bundle\\CatalogBundle\\Model\\ProductInterface, "%s" provided', ClassUtils::getClass($product))); } $options = $this->optionsResolver->resolveSaveOptions($options); $this->objectManager->persist($product); if (true === $options['schedule'] || true === $options['recalculate']) { $this->completenessManager->schedule($product); } if (true === $options['recalculate'] || true === $options['flush']) { $this->objectManager->flush(); } if (true === $options['recalculate']) { $this->completenessManager->generateMissingForProduct($product); } }