![]() 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/Ecombricks/InventoryInventoryCatalog/Model/SourceItemOption/ |
<?php /** * Copyright © eComBricks. All rights reserved. * See LICENSE.txt for license details. */ declare(strict_types=1); namespace Ecombricks\InventoryInventoryCatalog\Model\SourceItemOption; /** * Save source item options */ class Save implements \Ecombricks\InventoryInventoryCatalog\Api\SourceItemOption\SaveInterface { /** * Resource * * @var \Ecombricks\InventoryInventoryCatalog\Model\ResourceModel\SourceItemOption\Save */ protected $resource; /** * Surce item option label * * @var \Ecombricks\InventoryInventoryCatalog\Model\SourceItemOption\Label */ protected $sourceItemOptionLabel; /** * Logger * * @var \Psr\Log\LoggerInterface */ protected $logger; /** * Constructor * * @param \Ecombricks\InventoryInventoryCatalog\Model\ResourceModel\SourceItemOption\Save $resource * @param \Ecombricks\InventoryInventoryCatalog\Model\SourceItemOption\Label $sourceItemOptionLabel * @param \Psr\Log\LoggerInterface $logger * @return void */ public function __construct( \Ecombricks\InventoryInventoryCatalog\Model\ResourceModel\SourceItemOption\Save $resource, \Ecombricks\InventoryInventoryCatalog\Model\SourceItemOption\Label $sourceItemOptionLabel, \Psr\Log\LoggerInterface $logger ) { $this->resource = $resource; $this->sourceItemOptionLabel = $sourceItemOptionLabel; $this->logger = $logger; } /** * Execute * * @param \Magento\InventoryInventoryCatalog\Api\Data\SourceItemOptionInterface[] $sourceItemOptions * @return \Ecombricks\InventoryInventoryCatalog\Api\SourceItemOption\SaveInterface */ public function execute(array $sourceItemOptions): \Ecombricks\InventoryInventoryCatalog\Api\SourceItemOption\SaveInterface { $pluralLabel = $this->sourceItemOptionLabel->renderPlural(); if (empty($sourceItemOptions)) { throw new \Magento\Framework\Exception\InputException(__('No %1 to save.', $pluralLabel)); } try { $this->resource->execute($sourceItemOptions); } catch (\Exception $exception) { $this->logger->error($exception->getMessage()); throw new \Magento\Framework\Exception\CouldNotSaveException(__('Could not save %1.', $pluralLabel), $exception); } return $this; } }