použití contributte/scheduler ve vlastní DI extension
- Petr Parolek
- Člen | 455
Ahoj,
snažím se bez úspěchu zaregistrovat do DI extension vlastní úlohy contributte/schedule z neonu:
namespace X\Y\DI;
use Nette\Application\IPresenterFactory;
use Nette\DI\CompilerExtension;
class ZExtension extends CompilerExtension
{
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->loadFromFile(__DIR__ . '/config.neon');
$this->compiler->loadDefinitions(
$builder,
$config['services'],
$this->name
);
...
foreach ($config['scheduler']['jobs'] as $id => $job) {
$builder->addDefinition($this->prefix('jobs_' . $id))
->addTag('job')
->setFactory($job)
->setAutowired(true);
}
}
public function beforeCompile()
{
$builder = $this->getContainerBuilder();
$config = $this->loadFromFile(__DIR__ . '/config.neon');
...
foreach ($config['scheduler']['jobs'] as $id => $job) {
$job = new Statement($job);
$builder->getDefinition('jobs_' . $id)
->addSetup('run', [$job]);
}
}
}
config.neon:
scheduler:
jobs:
- A\B\CJob
- X\Y\ZJob
Vím, že na věc jdu úplně špatně. Poradí mi někdo prosím?
Editoval ppar (7. 1. 2019 19:47)