/** * @param AbstractModel $object * @return $this * @throws \Exception */ public function save(AbstractModel $object) { if ($object->isDeleted()) { return $this->delete($object); } $this->beginTransaction(); try { if (!$this->isModified($object)) { $this->processNotModifiedSave($object); $this->commit(); $object->setHasDataChanges(false); return $this; } $object->validateBeforeSave(); $object->beforeSave(); if ($object->isSaveAllowed()) { $this->_serializeFields($object); $this->_beforeSave($object); $this->_checkUnique($object); $this->objectRelationProcessor->validateDataIntegrity($this->getMainTable(), $object->getData()); $this->entityManager->save(PageInterface::class, $object); $this->unserializeFields($object); $this->processAfterSaves($object); } $this->addCommitCallback([$object, 'afterCommitCallback'])->commit(); $object->setHasDataChanges(false); } catch (\Exception $e) { $this->rollBack(); $object->setHasDataChanges(true); throw $e; } return $this; }
/** * {@inheritdoc} */ public function delete($object) { try { $this->transactionManager->start($this->getConnection()); if (is_numeric($object)) { } elseif ($object instanceof \Magento\Framework\Model\AbstractModel) { $object->beforeDelete(); } $this->_beforeDelete($object); $this->entityManager->delete(\Magento\Catalog\Api\Data\CategoryInterface::class, $object); $this->_afterDelete($object); if ($object instanceof \Magento\Framework\Model\AbstractModel) { $object->isDeleted(true); $object->afterDelete(); } $this->transactionManager->commit(); if ($object instanceof \Magento\Framework\Model\AbstractModel) { $object->afterDeleteCommit(); } } catch (\Exception $e) { $this->transactionManager->rollBack(); throw $e; } $this->_eventManager->dispatch('catalog_category_delete_after_done', ['product' => $object]); return $this; }
/** * @inheritDoc */ public function delete(AbstractModel $object) { $this->transactionManager->start($this->getConnection()); try { $object->beforeDelete(); $this->_beforeDelete($object); $this->entityManager->delete(PageInterface::class, $object); $this->_afterDelete($object); $object->isDeleted(true); $object->afterDelete(); $this->transactionManager->commit(); $object->afterDeleteCommit(); } catch (\Exception $e) { $this->transactionManager->rollBack(); throw $e; } return $this; }
/** * Delete the object * * @param \Magento\Framework\Model\AbstractModel $object * @return $this * @throws \Exception */ public function delete(AbstractModel $object) { $this->transactionManager->start($this->getConnection()); try { $object->beforeDelete(); $this->_beforeDelete($object); $this->entityManager->delete('Magento\\SalesRule\\Api\\Data\\RuleInterface', $object); $this->_afterDelete($object); $object->isDeleted(true); $object->afterDelete(); $this->transactionManager->commit(); $object->afterDeleteCommit(); } catch (\Exception $exception) { $this->transactionManager->rollBack(); throw $exception; } return $this; }
/** * @param AbstractModel $object * @return $this * @throws \Exception */ public function delete(\Magento\Framework\Model\AbstractModel $object) { //TODO: add object relation processor support (MAGETWO-49297) $this->transactionManager->start($this->getConnection()); try { $object->beforeDelete(); $this->_beforeDelete($object); $this->entityManager->delete('Magento\\CatalogRule\\Api\\Data\\RuleInterface', $object); $this->_afterDelete($object); $object->isDeleted(true); $object->afterDelete(); $this->transactionManager->commit(); $object->afterDeleteCommit(); } catch (\Exception $e) { $this->transactionManager->rollBack(); throw $e; } return $this; }
/** * {@inheritdoc} */ protected function processSave($object) { $this->entityManager->save(\Magento\Catalog\Api\Data\ProductInterface::class, $object); }
public function testDelete() { $this->orchestratorPool->expects($this->once())->method('getWriteOperation')->with('Test\\Entity\\Type', 'delete')->willReturn($this->writeOperation); $this->writeOperation->expects($this->once())->method('execute')->with('Test\\Entity\\Type', $this->abstractEntity)->willReturn(true); $this->assertTrue($this->subject->delete('Test\\Entity\\Type', $this->abstractEntity)); }