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/shiplab/Model/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

namespace Extmag\Shiplab\Model;

use Exception;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\NoSuchEntityException;

class DefaultRepository
{
    protected $entityName = 'Entity';

    protected $resource;

    protected $entityFactory;

    public function __construct($resource, $entityFactory)
    {
        $this->resource = $resource;
        $this->entityFactory = $entityFactory;
    }

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

        return $item;
    }

    /**
     * @throws CouldNotDeleteException
     * @throws NoSuchEntityException
     */
    public function deleteById($entityId)
    {
        return $this->delete($this->getById($entityId));
    }

    /**
     * @throws CouldNotDeleteException
     */
    public function delete($item)
    {
        try {
            $this->resource->delete($item);
        } catch (Exception $exception) {
            throw new CouldNotDeleteException(
                __(
                    'Could not delete the ' . $this->entityName . ': %1',
                    $exception->getMessage()
                )
            );
        }

        return true;
    }

    /**
     * @throws NoSuchEntityException
     */
    public function getById($entityId)
    {
        $page = $this->entityFactory->create();
        $this->resource->load($page, $entityId);
        if (!$page->getId()) {
            throw new NoSuchEntityException(
                __('The ' . $this->entityName . ' with the "%1" ID doesn\'t exist.', $entityId)
            );
        }

        return $page;
    }
}

Spamworldpro Mini