/** * @param ResourceCategory $resourceCategory * @param \Closure $proceed * @param AbstractModel $category * @return ResourceCategory * @throws \Exception */ private function addCommitCallback(ResourceCategory $resourceCategory, \Closure $proceed, AbstractModel $category) { try { $resourceCategory->beginTransaction(); $result = $proceed($category); $resourceCategory->addCommitCallback(function () use($category) { $affectedProducts = $category->getAffectedProductIds(); if (is_array($affectedProducts)) { $this->reindexList($affectedProducts); } }); $resourceCategory->commit(); } catch (\Exception $e) { $resourceCategory->rollBack(); throw $e; } return $result; }
/** * {@inheritdoc} */ public function rollBack() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'rollBack'); if (!$pluginInfo) { return parent::rollBack(); } else { return $this->___callPlugins('rollBack', func_get_args(), $pluginInfo); } }