![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/extmag/shiplab/Model/ |
<?php /** * Copyright © Extmag. All rights reserved. */ namespace Extmag\Shiplab\Model; use Extmag\Shiplab\Api\Data\PriceRulesInterface; use Extmag\Shiplab\Api\Data\PriceRulesInterfaceFactory; use Extmag\Shiplab\Api\PriceRulesRepositoryInterface; use Extmag\Shiplab\Model\ResourceModel\PriceRules as ResourcePriceRules; use Exception; use Magento\Framework\Exception\CouldNotDeleteException; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\NoSuchEntityException; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class PriceRulesRepository implements PriceRulesRepositoryInterface { /** * @var ResourcePriceRules */ protected $resource; /** * @var PriceRulesFactory */ protected $priceRulesFactory; /** * @param ResourcePriceRules $resource * @param PriceRulesFactory $priceRulesFactory */ public function __construct( ResourcePriceRules $resource, PriceRulesFactory $priceRulesFactory ) { $this->resource = $resource; $this->priceRulesFactory = $priceRulesFactory; } /** * Save PriceRules data * * @param PriceRulesInterface $item * @return PriceRulesInterface * @throws CouldNotSaveException */ public function save(PriceRulesInterface $item) { try { $this->resource->save($item); } catch (Exception $exception) { throw new CouldNotSaveException( __('Could not save the Price Rule: %1', $exception->getMessage()), $exception ); } return $item; } /** * Load PriceRules data by given PriceRules Identity * * @param string $itemId * @return PriceRulesInterface * @throws NoSuchEntityException */ public function getById($itemId) { $page = $this->priceRulesFactory->create(); $this->resource->load($page, $itemId); if (!$page->getId()) { throw new NoSuchEntityException(__('The Price Rule with the "%1" ID doesn\'t exist.', $itemId)); } return $page; } /** * Delete Page * * @param PriceRulesInterface $item * @return bool * @throws CouldNotDeleteException */ public function delete(PriceRulesInterface $item) { try { $this->resource->delete($item); } catch (Exception $exception) { throw new CouldNotDeleteException(__( 'Could not delete the Error: %1', $exception->getMessage() )); } return true; } /** * Delete PriceRules by given PriceRules Identity * * @param string $itemId * @return bool * @throws CouldNotDeleteException * @throws NoSuchEntityException */ public function deleteById($itemId) { return $this->delete($this->getById($itemId)); } }