feature/cierres #25

Open
aldarien wants to merge 446 commits from feature/cierres into develop
138 changed files with 471 additions and 4659 deletions
Showing only changes of commit ecc67a43c8 - Show all commits

View File

@ -0,0 +1,50 @@
<?php
namespace Incoviba\Service\Worker;
use Exception;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use Incoviba\Common\Ideal;
use Incoviba\Model;
use Incoviba\Service\Worker;
class Service extends Ideal\Service implements Worker
{
public function __construct(protected ContainerInterface $container ,LoggerInterface $logger)
{
parent::__construct($logger);
}
public function execute(Model\Job $job): bool
{
$configuration = $job->configuration;
$serviceClass = $configuration['service'];
$method = $configuration['method'];
$params = $configuration['params'] ?? [];
try {
$service = $this->container->get($serviceClass);
} catch (NotFoundExceptionInterface | ContainerExceptionInterface $exception) {
$this->logger->error($exception->getMessage());
return false;
}
try {
$result = call_user_func_array([$service, $method], $params);
} catch (Exception $exception) {
$this->logger->error($exception->getMessage(), [
'Worker' => __CLASS__,
'job_id' => $job->id,
'service' => $serviceClass,
'method' => $method,
'params' => $params,
'exception' => $exception
]);
return false;
}
if (is_bool($result)) {
return $result;
}
return true;
}
}