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 / dev2.destoffenstraat.com / app / code / Amasty / CronSchedule / Model /
Filename/home/dev2.destoffenstraat.com/app/code/Amasty/CronSchedule/Model/DataProvider.php
Size2.03 kb
Permissionrw-r--r--
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified14-Jun-2025 23:52
Last accessed22-Aug-2025 19:56
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) Amasty (https://www.amasty.com)
* @package Cron Schedule for Magento 2 (System)
*/

namespace Amasty\CronSchedule\Model;

use Magento\Framework\App\RequestInterface;
use Magento\Framework\Exception\LocalizedException;

//TODO move to api
class DataProvider
{
/**
* @var array
*/
private $dataProviders;

/**
* @var RequestInterface
*/
private $request;

public function __construct(
DataProvider\Basic $basic,
RequestInterface $request,
array $dataProviders = null
) {
$this->dataProviders = array_merge(['basic' => $basic], $dataProviders ?: []);
$this->request = $request;
}

/**
* @param $dataProviderType
*
* @return DataProvider\DataProviderInterface
* @throws LocalizedException
*/
public function getDataProvider($dataProviderType)
{
if (!isset($this->dataProviders[$dataProviderType])) {
throw new LocalizedException(__('Cron Schedule dataprovider "%1" is not exist', $dataProviderType));
}

if (!is_subclass_of(
$this->dataProviders[$dataProviderType],
DataProvider\DataProviderInterface::class
)) {
throw new LocalizedException(
__('Cron Schedule "%1" is not implement DataProviderInterface', $dataProviderType)
);
}

return $this->dataProviders[$dataProviderType];
}

public function getData($jobType, $dataProviderType = 'basic', $jobId = null)
{
return $this->getDataProvider($dataProviderType)->getData($jobType, $jobId);
}

public function getMeta($jobType, array $arguments = [], $dataProviderType = 'basic')
{
return $this->getDataProvider($dataProviderType)->getMeta($jobType, $arguments);
}

public function prepareSchedule($jobType, $dataProviderType = 'basic', $jobId = null)
{
return $this->getDataProvider($dataProviderType)->prepareSchedule($this->request, $jobType, $jobId);
}
}