|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / a / home / dev2.destoffenstraat.com / app / Firebear / ImportExport / Model / Import / |
Filename | /home/a/home/dev2.destoffenstraat.com/app/Firebear/ImportExport/Model/Import/HistoryRepository.php |
Size | 3.03 kb |
Permission | rwxr-xr-x |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 07-Nov-2022 06:44 |
Last accessed | 23-Aug-2025 04:58 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
/**
* @copyright: Copyright © 2017 Firebear Studio GmbH. All rights reserved.
* @author : Firebear Studio <fbeardev@gmail.com>
*/
namespace Firebear\ImportExport\Model\Import;
use Firebear\ImportExport\Api\Data\ImportHistoryInterface;
use Firebear\ImportExport\Api\HistoryRepositoryInterface;
use Firebear\ImportExport\Logger\Logger;
use Firebear\ImportExport\Model\ResourceModel\Import\History as ImportHistoryResource;
use Firebear\ImportExport\Model\ResourceModel\Import\History\CollectionFactory as ImportCollectionFactory;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\NoSuchEntityException;
/**
* Class JobRepository
*
* @package Firebear\ImportExport\Model
*/
class HistoryRepository implements HistoryRepositoryInterface
{
/**
* @var ImportHistoryResource
*/
protected $resource;
/**
* @var HistoryFactory
*/
protected $importFactory;
/**
* @var ImportCollectionFactory
*/
protected $importCollectionFactory;
/**
* @var Logger
*/
protected $logger;
/**
* JobRepository constructor.
*
* @param ImportHistoryResource $resource
* @param HistoryFactory $importFactory
* @param ImportCollectionFactory $importCollectionFactory
* @param Logger $logger
*/
public function __construct(
ImportHistoryResource $resource,
HistoryFactory $importFactory,
ImportCollectionFactory $importCollectionFactory,
Logger $logger
) {
$this->resource = $resource;
$this->importFactory = $importFactory;
$this->importCollectionFactory = $importCollectionFactory;
$this->logger = $logger;
}
/**
* {@inheritdoc}
*/
public function save(ImportHistoryInterface $history)
{
try {
$this->resource->save($history);
} catch (\Exception $exception) {
throw new CouldNotSaveException(__(
'Could not save the job: %1',
$exception->getMessage()
));
}
return $history;
}
/**
* {@inheritdoc}
*/
public function getById($historyId)
{
$history = $this->importFactory->create();
$this->resource->load($history, $historyId);
if (!$history->getId()) {
throw new NoSuchEntityException(__('Import History with id "%1" does not exist.', $historyId));
}
return $history;
}
/**
* {@inheritdoc}
*/
public function delete(ImportHistoryInterface $history)
{
try {
$this->resource->delete($history);
} catch (\Exception $exception) {
throw new CouldNotDeleteException(__(
'Could not delete the job: %1',
$exception->getMessage()
));
}
return true;
}
/**
* {@inheritdoc}
*/
public function deleteById($historyId)
{
return $this->delete($this->getById($historyId));
}
}
/**
* @copyright: Copyright © 2017 Firebear Studio GmbH. All rights reserved.
* @author : Firebear Studio <fbeardev@gmail.com>
*/
namespace Firebear\ImportExport\Model\Import;
use Firebear\ImportExport\Api\Data\ImportHistoryInterface;
use Firebear\ImportExport\Api\HistoryRepositoryInterface;
use Firebear\ImportExport\Logger\Logger;
use Firebear\ImportExport\Model\ResourceModel\Import\History as ImportHistoryResource;
use Firebear\ImportExport\Model\ResourceModel\Import\History\CollectionFactory as ImportCollectionFactory;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\NoSuchEntityException;
/**
* Class JobRepository
*
* @package Firebear\ImportExport\Model
*/
class HistoryRepository implements HistoryRepositoryInterface
{
/**
* @var ImportHistoryResource
*/
protected $resource;
/**
* @var HistoryFactory
*/
protected $importFactory;
/**
* @var ImportCollectionFactory
*/
protected $importCollectionFactory;
/**
* @var Logger
*/
protected $logger;
/**
* JobRepository constructor.
*
* @param ImportHistoryResource $resource
* @param HistoryFactory $importFactory
* @param ImportCollectionFactory $importCollectionFactory
* @param Logger $logger
*/
public function __construct(
ImportHistoryResource $resource,
HistoryFactory $importFactory,
ImportCollectionFactory $importCollectionFactory,
Logger $logger
) {
$this->resource = $resource;
$this->importFactory = $importFactory;
$this->importCollectionFactory = $importCollectionFactory;
$this->logger = $logger;
}
/**
* {@inheritdoc}
*/
public function save(ImportHistoryInterface $history)
{
try {
$this->resource->save($history);
} catch (\Exception $exception) {
throw new CouldNotSaveException(__(
'Could not save the job: %1',
$exception->getMessage()
));
}
return $history;
}
/**
* {@inheritdoc}
*/
public function getById($historyId)
{
$history = $this->importFactory->create();
$this->resource->load($history, $historyId);
if (!$history->getId()) {
throw new NoSuchEntityException(__('Import History with id "%1" does not exist.', $historyId));
}
return $history;
}
/**
* {@inheritdoc}
*/
public function delete(ImportHistoryInterface $history)
{
try {
$this->resource->delete($history);
} catch (\Exception $exception) {
throw new CouldNotDeleteException(__(
'Could not delete the job: %1',
$exception->getMessage()
));
}
return true;
}
/**
* {@inheritdoc}
*/
public function deleteById($historyId)
{
return $this->delete($this->getById($historyId));
}
}