122 lines
2.8 KiB
PHP
122 lines
2.8 KiB
PHP
<?php
|
|
|
|
abstract class stTaskSchedulerImportBaseAbstract
|
|
{
|
|
const DELAY = 1000;
|
|
const LIMIT = 20;
|
|
|
|
/**
|
|
*
|
|
* @var stTask
|
|
*/
|
|
private $task;
|
|
|
|
/**
|
|
*
|
|
* @var stTaskSchedulerImportCategoryMapper|null
|
|
*/
|
|
private $categoryMapper = null;
|
|
|
|
/**
|
|
*
|
|
* @var stTaskSchedulerImportProductUtility
|
|
*/
|
|
private $productUtility;
|
|
|
|
private $configuration;
|
|
|
|
public function __construct(stTask $task, stTaskSchedulerImportConfigurationInterface $configuration)
|
|
{
|
|
$this->task = $task;
|
|
$this->configuration = $configuration;
|
|
}
|
|
|
|
abstract public function process(array $data);
|
|
|
|
public function isReadyToExecute(): bool
|
|
{
|
|
return $this->task->isReadyToExecute();
|
|
}
|
|
|
|
/**
|
|
* Zwraca ilość rekordów do przetworzenia
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function getLimit(): int
|
|
{
|
|
return self::LIMIT;
|
|
}
|
|
|
|
/**
|
|
* Zwraca czas odstępu pomiędzy importem danych
|
|
*
|
|
* @return integer Czas wyrażony w ms
|
|
*/
|
|
public function getDelay(): int
|
|
{
|
|
return self::DELAY;
|
|
}
|
|
|
|
final public function getLogger(): stTaskLoggerInterface
|
|
{
|
|
return $this->task->getLogger();
|
|
}
|
|
|
|
/**
|
|
* Zwraca instancje klasy do obsługi kategorii
|
|
*
|
|
* @return stTaskSchedulerImportCategoryMapper
|
|
*/
|
|
final public function getCategoryMapper(): stTaskSchedulerImportCategoryMapper
|
|
{
|
|
if (null === $this->categoryMapper)
|
|
{
|
|
$this->categoryMapper = new stTaskSchedulerImportCategoryMapper($this);
|
|
}
|
|
|
|
return $this->categoryMapper;
|
|
}
|
|
|
|
/**
|
|
* Zwraca instancje klasy pomocniczej do operacji na produkcie
|
|
*
|
|
* @return stTaskSchedulerImportProductUtility
|
|
*/
|
|
final public function getProductUtility(): stTaskSchedulerImportProductUtility
|
|
{
|
|
if (null === $this->productUtility)
|
|
{
|
|
$this->productUtility = new stTaskSchedulerImportProductUtility($this);
|
|
}
|
|
|
|
return $this->productUtility;
|
|
}
|
|
|
|
final public function setParameter(string $name, $value)
|
|
{
|
|
$this->task->setParameter($name, $value);
|
|
}
|
|
|
|
final public function getParameter(string $name, $default = null)
|
|
{
|
|
return $this->task->getParameter($name, $default);
|
|
}
|
|
|
|
final public function getConfigurationParameter(string $name, $default = null)
|
|
{
|
|
return $this->configuration->getUserOption($name, $default);
|
|
}
|
|
|
|
final public function getConfiguration(): stTaskSchedulerImportConfigurationInterface
|
|
{
|
|
return $this->configuration;
|
|
}
|
|
|
|
final public function clearStaticPools()
|
|
{
|
|
ProductOptionsValue::clearStaticPool();
|
|
stNewProductOptions::clearStaticPool();
|
|
sfAsset::clearStaticPool();
|
|
}
|
|
} |