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/cartforge.co/app/code/Amasty/Base/Model/InstanceHash/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/Amasty/Base/Model/InstanceHash/Repository.php
<?php

declare(strict_types=1);

/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Magento 2 Base Package
 */

namespace Amasty\Base\Model\InstanceHash;

use Amasty\Base\Api\Data\InstanceHashInterface;
use Amasty\Base\Api\Data\InstanceHashInterfaceFactory;
use Amasty\Base\Api\InstanceHashRepositoryInterface;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\NoSuchEntityException;

class Repository implements InstanceHashRepositoryInterface
{
    /**
     * @var ResourceModel\InstanceHash
     */
    private $instanceHashResource;

    /**
     * @var InstanceDataInterfaceFactory
     */
    private $instanceHashFactory;

    public function __construct(
        ResourceModel\InstanceHash $instanceHashResource,
        InstanceHashInterfaceFactory $instanceHashFactory
    ) {
        $this->instanceHashResource = $instanceHashResource;
        $this->instanceHashFactory = $instanceHashFactory;
    }

    public function get(string $code): InstanceHashInterface
    {
        $instanceData = $this->instanceHashFactory->create();
        $this->instanceHashResource->load($instanceData, $code, InstanceHashInterface::CODE);
        if (!$instanceData->getId()) {
            throw new NoSuchEntityException(__('Instance Hash Data with code "%1" not found.', $code));
        }

        return $instanceData;
    }

    public function save(InstanceHashInterface $instanceHash): void
    {
        try {
            try {
                /** @var InstanceHash $instanceHashSaved */
                $instanceHashSaved = $this->get($instanceHash->getCode());
                $instanceHashSaved->addData($instanceHash->getData());
                $instanceHash = $instanceHashSaved;
                //phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
            } catch (NoSuchEntityException $e) {
            }
            $this->instanceHashResource->save($instanceHash);
        } catch (\Exception $e) {
            throw new CouldNotSaveException(__('Unable to save the Instance Data. Error: %1', $e->getMessage()));
        }
    }

    public function delete(string $code): void
    {
        try {
            $instanceHash = $this->get($code);
            $this->instanceHashResource->delete($instanceHash);
            //phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
        } catch (NoSuchEntityException $e) {
        } catch (\Exception $e) {
            throw new CouldNotDeleteException(
                __('Could not delete Instance Hash with code %1. Error: "%2"', $code, $e->getMessage())
            );
        }
    }
}

Spamworldpro Mini