Job parameter accessor
When a job (or a component within a job) can be working with a parameterized value, it can rely on a JobParameterAccessorInterface instance to retrieve that value.
<?php
use Yokai\Batch\Job\JobInterface;
use Yokai\Batch\Job\Parameters\JobParameterAccessorInterface;
use Yokai\Batch\JobExecution;
class FooJob implements JobInterface
{
public function __construct(
private JobParameterAccessorInterface $path,
) {
}
public function execute(JobExecution $jobExecution): void
{
/** @var string $path */
$path = $this->path->get($jobExecution);
// do something with $path
}
}
What types of parameter accessors exists?
Built-in parameter accessors:
ChainParameterAccessor: try multiple parameter accessors, the first that is not failing is used.
ClosestJobExecutionAccessor: try another parameter accessor on each job execution in hierarchy, until not failed.
DefaultParameterAccessor: try accessing parameter using another parameter accessor, use default value if failed.
JobExecutionParameterAccessor: extract value from job execution’s parameters.
JobExecutionSummaryAccessor: extract value from job execution’s summary.
ParentJobExecutionAccessor: use another parameter accessor on job execution’s parent execution.
ReplaceWithVariablesParameterAccessor: use another parameter accessor to get string value, and replace variables before returning.
RootJobExecutionAccessor: use another parameter accessor on job execution’s root execution.
SiblingJobExecutionAccessor: use another parameter accessor on job execution’s sibling execution.
StaticValueParameterAccessor: use static value provided at construction.
Parameter accessors from bridges:
From
symfony/framework-bundlebridge:ContainerParameterAccessor: use a parameter from Symfony’s container.