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/extmag/core/Model/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/extmag/core/Model/ConfigRepository.php
<?php
/**
 * Copyright © Extmag. All rights reserved.
 */

namespace Extmag\Core\Model;

use Exception;
use Extmag\Core\Api\ConfigRepositoryInterface;
use Extmag\Core\Api\Data;
use Extmag\Core\Api\Data\ConfigInterface;
use Extmag\Core\Api\Data\ConfigInterfaceFactory;
use Extmag\Core\Api\Data\ConfigSearchResultsInterface;
use Extmag\Core\Model\ResourceModel\Config as ResourceConfig;
use Extmag\Core\Model\ResourceModel\Config\Collection;
use Extmag\Core\Model\ResourceModel\Config\CollectionFactory as ConfigCollectionFactory;
use Magento\Framework\Api\DataObjectHelper;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Reflection\DataObjectProcessor;

/**
 * Class ConfigRepository
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
class ConfigRepository implements ConfigRepositoryInterface
{
    /**
     * @var ResourceConfig
     */
    protected $resource;

    /**
     * @var ConfigFactory
     */
    protected $configFactory;

    /**
     * @var ConfigCollectionFactory
     */
    protected $configCollectionFactory;

    /**
     * @var Data\ConfigSearchResultsInterfaceFactory
     */
    protected $searchResultsFactory;

    /**
     * @var DataObjectHelper
     */
    protected $dataObjectHelper;

    /**
     * @var DataObjectProcessor
     */
    protected $dataObjectProcessor;

    /**
     * @var ConfigInterfaceFactory
     */
    protected $dataConfigFactory;
    /**
     * @var CollectionProcessorInterface
     */
    private $collectionProcessor;

    /**
     * @param ResourceConfig $resource
     * @param ConfigFactory $configFactory
     * @param ConfigInterfaceFactory $dataConfigFactory
     * @param ConfigCollectionFactory $pageCollectionFactory
     * @param Data\ConfigSearchResultsInterfaceFactory $searchResultsFactory
     * @param DataObjectHelper $dataObjectHelper
     * @param DataObjectProcessor $dataObjectProcessor
     * @param CollectionProcessorInterface $collectionProcessor
     */
    public function __construct(
        ResourceConfig $resource,
        ConfigFactory $configFactory,
        ConfigInterfaceFactory $dataConfigFactory,
        ConfigCollectionFactory $pageCollectionFactory,
        Data\ConfigSearchResultsInterfaceFactory $searchResultsFactory,
        DataObjectHelper $dataObjectHelper,
        DataObjectProcessor $dataObjectProcessor,
        CollectionProcessorInterface $collectionProcessor
    ) {
        $this->resource = $resource;
        $this->configFactory = $configFactory;
        $this->configCollectionFactory = $pageCollectionFactory;
        $this->searchResultsFactory = $searchResultsFactory;
        $this->dataObjectHelper = $dataObjectHelper;
        $this->dataConfigFactory = $dataConfigFactory;
        $this->dataObjectProcessor = $dataObjectProcessor;
        $this->collectionProcessor = $collectionProcessor;
    }

    /**
     * Save Config data
     *
     * @param ConfigInterface $item
     * @return ConfigInterface
     * @throws CouldNotSaveException
     */
    public function save(ConfigInterface $item)
    {
        try {
            $this->resource->save($item);
        } catch (Exception $exception) {
            throw new CouldNotSaveException(
                __('Could not save the item: %1', $exception->getMessage()),
                $exception
            );
        }

        return $item;
    }

    /**
     * Load Config data by given Config Identity
     *
     * @param string $itemId
     * @return Config
     * @throws NoSuchEntityException
     */
    public function getById($itemId)
    {
        $page = $this->configFactory->create();
        $this->resource->load($page, $itemId);
        if (!$page->getId()) {
            throw new NoSuchEntityException(__('The config item with the "%1" ID doesn\'t exist.', $itemId));
        }
        return $page;
    }

    /**
     * Load Config data collection by given search criteria
     *
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     * @param SearchCriteriaInterface $criteria
     * @return ConfigSearchResultsInterface
     */
    public function getList(SearchCriteriaInterface $criteria)
    {
        /** @var Collection $collection */
        $collection = $this->configCollectionFactory->create();

        $this->collectionProcessor->process($criteria, $collection);

        /** @var ConfigSearchResultsInterface $searchResults */
        $searchResults = $this->searchResultsFactory->create();
        $searchResults->setSearchCriteria($criteria);
        $searchResults->setItems($collection->getItems());
        $searchResults->setTotalCount($collection->getSize());
        return $searchResults;
    }

    /**
     * Delete Page
     *
     * @param ConfigInterface $item
     * @return bool
     * @throws CouldNotDeleteException
     */
    public function delete(ConfigInterface $item)
    {
        try {
            $this->resource->delete($item);
        } catch (Exception $exception) {
            throw new CouldNotDeleteException(__(
                'Could not delete the Error: %1',
                $exception->getMessage()
            ));
        }
        return true;
    }

    /**
     * Delete Config by given Config Identity
     *
     * @param string $itemId
     * @return bool
     * @throws CouldNotDeleteException
     * @throws NoSuchEntityException
     */
    public function deleteById($itemId)
    {
        return $this->delete($this->getById($itemId));
    }
}

Spamworldpro Mini