Loading module/Application/src/Factory/AutowireFactory.php +47 Changes for module/Application/src/Factory/AutowireFactory.php: 47 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Application\Factory; use Psr\Container\ContainerInterface; /** * Description of AutowireFactory * * @author Laurent Lécluse <laurent.lecluse at unicaen.fr> */ class AutowireFactory { public function __invoke(ContainerInterface $container, string $requestedName, ?array $options = null): object { return $this->createService($container, $requestedName); } protected function createService(ContainerInterface $container, string $requestedName): object { if (!class_exists($requestedName)) { throw new \Exception('La classe "' . $requestedName . '" n\'a pas été trouvée'); } $reflection = new \ReflectionClass($requestedName); $constructor = $reflection->getConstructor(); if ($constructor === null) { return new $requestedName(); } $parameters = $constructor->getParameters(); $dependencies = []; foreach ($parameters as $parameter) { $dependencyName = $parameter->getType()->getName(); $dependencies[] = $container->get($dependencyName); } return new $requestedName(...$dependencies); } } No newline at end of file module/Workflow/config/module.config.php +2 −1 Changes for module/Workflow/config/module.config.php: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Workflow; use Application\Factory\AutowireFactory; use Application\Provider\Privilege\Privileges; use UnicaenPrivilege\Assertion\AssertionFactory; Loading Loading @@ -66,7 +67,7 @@ return [ 'services' => [ Service\WorkflowService::class => Service\WorkflowServiceFactory::class, Tbl\Process\WorkflowProcess::class => Tbl\Process\WorkflowProcessFactory::class, Tbl\Process\WorkflowProcess::class => AutowireFactory::class, Service\WfEtapeDepService::class => Service\WfEtapeDepServiceFactory::class, Service\WfEtapeService::class => Service\WfEtapeServiceFactory::class, Service\TypeValidationService::class => Service\TypeValidationServiceFactory::class, Loading module/Workflow/src/Tbl/Process/WorkflowProcess.php +24 −14 Changes for module/Workflow/src/Tbl/Process/WorkflowProcess.php: 24 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -4,14 +4,14 @@ namespace Workflow\Tbl\Process; use Application\Cache\Traits\CacheContainerTrait; use Application\Service\Traits\AnneeServiceAwareTrait; use Unicaen\BddAdmin\BddAwareTrait; use Application\Service\AnneeService; use Unicaen\BddAdmin\Bdd; use UnicaenTbl\Event; use UnicaenTbl\Process\ProcessInterface; use UnicaenTbl\Service\BddServiceAwareTrait; use UnicaenTbl\Service\BddService; use UnicaenTbl\TableauBord; use Workflow\Entity\Db\WorkflowEtape; use Workflow\Service\WorkflowServiceAwareTrait; use Workflow\Service\WorkflowService; use Workflow\Tbl\Process\Model\IntervenantEtape; use Workflow\Tbl\Process\Model\IntervenantEtapeStructure; use Workflow\Tbl\Process\Sub\Calculateur; Loading @@ -23,10 +23,6 @@ use Workflow\Tbl\Process\Sub\Calculateur; */ class WorkflowProcess implements ProcessInterface { use BddServiceAwareTrait; use BddAwareTrait; use AnneeServiceAwareTrait; use WorkflowServiceAwareTrait; use CacheContainerTrait; /** Loading @@ -38,19 +34,33 @@ class WorkflowProcess implements ProcessInterface public function __construct() public function __construct( private readonly BddService $bddService, private readonly Bdd $bdd, private readonly AnneeService $anneeService, private readonly WorkflowService $workflowService, ) { $this->calculateur = new Calculateur(); } public function test() { $bdd = $this->bdd; dd($this->bdd->select('select * from annee where id = 2024')); } public function run(TableauBord $tableauBord, array $params = []): void { mpg_lower($params); if (empty($params)) { $annees = $this->getServiceAnnee()->getActives(true); $annees = $this->anneeService->getActives(true); foreach ($annees as $annee) { $this->run($tableauBord, ['annee_id' => $annee->getId()]); } Loading @@ -73,9 +83,9 @@ class WorkflowProcess implements ProcessInterface $cache->alimentationSql = $this->makeSql(); //} $etapes = $this->getServiceWorkflow()->getEtapes(); $etapes = $this->workflowService->getEtapes(); $sql = $this->getServiceBdd()->injectKey($cache->alimentationSql, $params); $sql = $this->bddService->injectKey($cache->alimentationSql, $params); $stmt = $this->bdd->selectEach($sql); while ($d = $stmt->next()) { mpg_lower($d); Loading Loading @@ -152,7 +162,7 @@ class WorkflowProcess implements ProcessInterface // Enregistrement en BDD $key = $tableauBord->getOption('key'); $table = $this->getBdd()->getTable($tableName); $table = $this->bdd->getTable($tableName); // on force la DDL pour éviter de faire des requêtes en plus // $table->setDdl(['sequence' => $tableauBord->getOption('sequence'), 'columns' => array_fill_keys($tableauBord->getOption('cols'), [])]); Loading @@ -170,7 +180,7 @@ class WorkflowProcess implements ProcessInterface // on force le refresh des feuilles de route déjà chargées foreach ($this->workflows as $intervenant => $workflow) { $this->getServiceWorkflow()->refreshFeuilleDeRoute($intervenant); $this->workflowService->refreshFeuilleDeRoute($intervenant); } } Loading module/Workflow/src/Tbl/Process/WorkflowProcessAwareTrait.php −x−35 File deleted. Show changes module/Workflow/src/Tbl/Process/WorkflowProcessFactory.php −x−34 File deleted. Show changes Loading
module/Application/src/Factory/AutowireFactory.php +47 Changes for module/Application/src/Factory/AutowireFactory.php: 47 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace Application\Factory; use Psr\Container\ContainerInterface; /** * Description of AutowireFactory * * @author Laurent Lécluse <laurent.lecluse at unicaen.fr> */ class AutowireFactory { public function __invoke(ContainerInterface $container, string $requestedName, ?array $options = null): object { return $this->createService($container, $requestedName); } protected function createService(ContainerInterface $container, string $requestedName): object { if (!class_exists($requestedName)) { throw new \Exception('La classe "' . $requestedName . '" n\'a pas été trouvée'); } $reflection = new \ReflectionClass($requestedName); $constructor = $reflection->getConstructor(); if ($constructor === null) { return new $requestedName(); } $parameters = $constructor->getParameters(); $dependencies = []; foreach ($parameters as $parameter) { $dependencyName = $parameter->getType()->getName(); $dependencies[] = $container->get($dependencyName); } return new $requestedName(...$dependencies); } } No newline at end of file
module/Workflow/config/module.config.php +2 −1 Changes for module/Workflow/config/module.config.php: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Workflow; use Application\Factory\AutowireFactory; use Application\Provider\Privilege\Privileges; use UnicaenPrivilege\Assertion\AssertionFactory; Loading Loading @@ -66,7 +67,7 @@ return [ 'services' => [ Service\WorkflowService::class => Service\WorkflowServiceFactory::class, Tbl\Process\WorkflowProcess::class => Tbl\Process\WorkflowProcessFactory::class, Tbl\Process\WorkflowProcess::class => AutowireFactory::class, Service\WfEtapeDepService::class => Service\WfEtapeDepServiceFactory::class, Service\WfEtapeService::class => Service\WfEtapeServiceFactory::class, Service\TypeValidationService::class => Service\TypeValidationServiceFactory::class, Loading
module/Workflow/src/Tbl/Process/WorkflowProcess.php +24 −14 Changes for module/Workflow/src/Tbl/Process/WorkflowProcess.php: 24 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -4,14 +4,14 @@ namespace Workflow\Tbl\Process; use Application\Cache\Traits\CacheContainerTrait; use Application\Service\Traits\AnneeServiceAwareTrait; use Unicaen\BddAdmin\BddAwareTrait; use Application\Service\AnneeService; use Unicaen\BddAdmin\Bdd; use UnicaenTbl\Event; use UnicaenTbl\Process\ProcessInterface; use UnicaenTbl\Service\BddServiceAwareTrait; use UnicaenTbl\Service\BddService; use UnicaenTbl\TableauBord; use Workflow\Entity\Db\WorkflowEtape; use Workflow\Service\WorkflowServiceAwareTrait; use Workflow\Service\WorkflowService; use Workflow\Tbl\Process\Model\IntervenantEtape; use Workflow\Tbl\Process\Model\IntervenantEtapeStructure; use Workflow\Tbl\Process\Sub\Calculateur; Loading @@ -23,10 +23,6 @@ use Workflow\Tbl\Process\Sub\Calculateur; */ class WorkflowProcess implements ProcessInterface { use BddServiceAwareTrait; use BddAwareTrait; use AnneeServiceAwareTrait; use WorkflowServiceAwareTrait; use CacheContainerTrait; /** Loading @@ -38,19 +34,33 @@ class WorkflowProcess implements ProcessInterface public function __construct() public function __construct( private readonly BddService $bddService, private readonly Bdd $bdd, private readonly AnneeService $anneeService, private readonly WorkflowService $workflowService, ) { $this->calculateur = new Calculateur(); } public function test() { $bdd = $this->bdd; dd($this->bdd->select('select * from annee where id = 2024')); } public function run(TableauBord $tableauBord, array $params = []): void { mpg_lower($params); if (empty($params)) { $annees = $this->getServiceAnnee()->getActives(true); $annees = $this->anneeService->getActives(true); foreach ($annees as $annee) { $this->run($tableauBord, ['annee_id' => $annee->getId()]); } Loading @@ -73,9 +83,9 @@ class WorkflowProcess implements ProcessInterface $cache->alimentationSql = $this->makeSql(); //} $etapes = $this->getServiceWorkflow()->getEtapes(); $etapes = $this->workflowService->getEtapes(); $sql = $this->getServiceBdd()->injectKey($cache->alimentationSql, $params); $sql = $this->bddService->injectKey($cache->alimentationSql, $params); $stmt = $this->bdd->selectEach($sql); while ($d = $stmt->next()) { mpg_lower($d); Loading Loading @@ -152,7 +162,7 @@ class WorkflowProcess implements ProcessInterface // Enregistrement en BDD $key = $tableauBord->getOption('key'); $table = $this->getBdd()->getTable($tableName); $table = $this->bdd->getTable($tableName); // on force la DDL pour éviter de faire des requêtes en plus // $table->setDdl(['sequence' => $tableauBord->getOption('sequence'), 'columns' => array_fill_keys($tableauBord->getOption('cols'), [])]); Loading @@ -170,7 +180,7 @@ class WorkflowProcess implements ProcessInterface // on force le refresh des feuilles de route déjà chargées foreach ($this->workflows as $intervenant => $workflow) { $this->getServiceWorkflow()->refreshFeuilleDeRoute($intervenant); $this->workflowService->refreshFeuilleDeRoute($intervenant); } } Loading