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 /
Filename/home/a/home/dev2.destoffenstraat.com/app/Firebear/ImportExport/Model/ExportJobRepository.php
Size3.43 kb
Permissionrwxr-xr-x
Ownerroot : root
Create time21-Aug-2025 12:26
Last modified07-Nov-2022 06:44
Last accessed22-Aug-2025 22:34
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;

use Magento\Framework\Exception\CouldNotDeleteException;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Validation\ValidationException;
use Firebear\ImportExport\Api\Export\SaveInterface;
use Firebear\ImportExport\Api\ExportJobRepositoryInterface;
use Firebear\ImportExport\Model\ResourceModel\ExportJob as ExportJobResource;
use Firebear\ImportExport\Model\ExportJobFactory;
use Firebear\ImportExport\Model\ResourceModel\ExportJob\CollectionFactory as ExportCollectionFactory;

/**
* Class ExportJobRepository
*
* @package Firebear\ImportExport\Model
*/
class ExportJobRepository implements ExportJobRepositoryInterface
{
/**
* @var ExportJobResource
*/
protected $resource;

/**
* @var \Firebear\ImportExport\Model\ExportJobFactory
*/
protected $exportFactory;

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

/**
* @var SaveInterface
*/
private $saveCommand;

/**
* ExportJobRepository constructor.
*
* @param ExportJobResource $resource
* @param \Firebear\ImportExport\Model\ExportJobFactory $exportFactory
* @param ExportCollectionFactory $exportCollectionFactory
* @param SaveInterface $saveCommand
*/
public function __construct(
ExportJobResource $resource,
ExportJobFactory $exportFactory,
ExportCollectionFactory $exportCollectionFactory,
SaveInterface $saveCommand
) {
$this->resource = $resource;
$this->exportFactory = $exportFactory;
$this->exportCollectionFactory = $exportCollectionFactory;
$this->saveCommand = $saveCommand;
}

/**
* @param \Firebear\ImportExport\Api\Data\ExportInterface $job
*
* @return \Firebear\ImportExport\Api\Data\ExportInterface
* @throws CouldNotSaveException
* @throws ValidationException
*/
public function save(\Firebear\ImportExport\Api\Data\ExportInterface $job)
{
return $this->saveCommand->execute($job);
}

/**
* @param $jobId
*
* @return mixed
* @throws NoSuchEntityException
*/
public function getById($jobId)
{
$job = $this->exportFactory->create();
$this->resource->load($job, $jobId);
if (!$job->getId()) {
throw new NoSuchEntityException(__('Job with id "%1" does not exist.', $jobId));
}

return $job;
}

/**
* @param \Firebear\ImportExport\Api\Data\ExportInterface $job
*
* @return bool
* @throws CouldNotDeleteException
*/
public function delete(\Firebear\ImportExport\Api\Data\ExportInterface $job)
{
try {
$this->resource->delete($job);
} catch (\Exception $exception) {
throw new CouldNotDeleteException(
__(
'Could not delete the job: %1',
$exception->getMessage()
)
);
}

return true;
}

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