Spamworldpro Mini Shell
Spamworldpro


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/magento/module-catalog/Model/Product/Attribute/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-catalog/Model/Product/Attribute/OptionManagement.php
<?php
/**
 * @author      Magento Core Team <[email protected]>
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Catalog\Model\Product\Attribute;

use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Api\ProductAttributeOptionManagementInterface;
use Magento\Catalog\Api\ProductAttributeOptionUpdateInterface;
use Magento\Eav\Api\AttributeOptionManagementInterface;
use Magento\Eav\Api\AttributeOptionUpdateInterface;
use Magento\Eav\Api\Data\AttributeOptionInterface;
use Magento\Framework\Exception\InputException;

/**
 * Option management model for product attribute.
 */
class OptionManagement implements ProductAttributeOptionManagementInterface, ProductAttributeOptionUpdateInterface
{
    /**
     * @var AttributeOptionManagementInterface
     */
    protected $eavOptionManagement;

    /**
     * @var AttributeOptionUpdateInterface
     */
    private $eavOptionUpdate;

    /**
     * @param AttributeOptionManagementInterface $eavOptionManagement
     * @param AttributeOptionUpdateInterface $eavOptionUpdate
     */
    public function __construct(
        AttributeOptionManagementInterface $eavOptionManagement,
        AttributeOptionUpdateInterface $eavOptionUpdate
    ) {
        $this->eavOptionManagement = $eavOptionManagement;
        $this->eavOptionUpdate = $eavOptionUpdate;
    }

    /**
     * @inheritdoc
     */
    public function getItems($attributeCode)
    {
        return $this->eavOptionManagement->getItems(
            ProductAttributeInterface::ENTITY_TYPE_CODE,
            $attributeCode
        );
    }

    /**
     * @inheritdoc
     */
    public function add($attributeCode, $option)
    {
        return $this->eavOptionManagement->add(
            ProductAttributeInterface::ENTITY_TYPE_CODE,
            $attributeCode,
            $option
        );
    }

    /**
     * @inheritdoc
     */
    public function update(string $attributeCode, int $optionId, AttributeOptionInterface $option): bool
    {
        return $this->eavOptionUpdate->update(
            ProductAttributeInterface::ENTITY_TYPE_CODE,
            $attributeCode,
            $optionId,
            $option
        );
    }

    /**
     * @inheritdoc
     */
    public function delete($attributeCode, $optionId)
    {
        if (empty($optionId)) {
            throw new InputException(__('Invalid option id %1', $optionId));
        }

        return $this->eavOptionManagement->delete(
            ProductAttributeInterface::ENTITY_TYPE_CODE,
            $attributeCode,
            $optionId
        );
    }
}

Spamworldpro Mini