Loading module/Workflow/src/Model/FeuilleDeRoute.php +22 −15 Changes for module/Workflow/src/Model/FeuilleDeRoute.php: 22 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ class FeuilleDeRoute */ private array $fdr = []; private ?string $couranteCache = null; private bool $builted = false; Loading @@ -42,6 +44,7 @@ class FeuilleDeRoute { $this->fdr = []; $this->builted = false; $this->couranteCache = null; } Loading Loading @@ -103,12 +106,19 @@ class FeuilleDeRoute public function getCourante(): ?FeuilleDeRouteEtape { return null; if (!$this->couranteCache) { $wfEtape = $this->getNext(); if ($wfEtape){ $this->couranteCache = $wfEtape->getCode(); } } return $this->fdr[$this->couranteCache] ?? null; } public function getNext(string|WorkflowEtape|FeuilleDeRouteEtape $etape): ?FeuilleDeRouteEtape public function getNext(string|WorkflowEtape|FeuilleDeRouteEtape|null $etape = null, bool $needAllowed = true): ?FeuilleDeRouteEtape { if (!$this->builted) { $this->build(); Loading @@ -121,22 +131,19 @@ class FeuilleDeRoute $etape = $etape->workflowEtape->getCode(); } return null; /** @TODO */ } // Si l'étape n'est pas précisée, on est déjà dans la prochaine $isNext = $etape === null; public function getPrevious(string|WorkflowEtape|FeuilleDeRouteEtape $etape): ?FeuilleDeRouteEtape { if (!$this->builted) { $this->build(); foreach($this->fdr as $code => $wfEtape){ if ($isNext){ if ($wfEtape->atteignable && !$wfEtape->isFranchie()){ if (!$needAllowed || $wfEtape->isAllowed()){ return $wfEtape; } if ($etape instanceof WorkflowEtape) { $etape = $etape->getCode(); } if ($etape instanceof FeuilleDeRouteEtape) { $etape = $etape->workflowEtape->getCode(); }elseif($code === $etape){ $isNext = true; } } return null; /** @TODO */ Loading module/Workflow/src/Model/FeuilleDeRouteEtape.php +6 Changes for module/Workflow/src/Model/FeuilleDeRouteEtape.php: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -60,6 +60,12 @@ class FeuilleDeRouteEtape public function isFranchie(): bool { return $this->realisation >= $this->objectif; } public function isAllowed(): bool { return true; Loading Loading
module/Workflow/src/Model/FeuilleDeRoute.php +22 −15 Changes for module/Workflow/src/Model/FeuilleDeRoute.php: 22 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ class FeuilleDeRoute */ private array $fdr = []; private ?string $couranteCache = null; private bool $builted = false; Loading @@ -42,6 +44,7 @@ class FeuilleDeRoute { $this->fdr = []; $this->builted = false; $this->couranteCache = null; } Loading Loading @@ -103,12 +106,19 @@ class FeuilleDeRoute public function getCourante(): ?FeuilleDeRouteEtape { return null; if (!$this->couranteCache) { $wfEtape = $this->getNext(); if ($wfEtape){ $this->couranteCache = $wfEtape->getCode(); } } return $this->fdr[$this->couranteCache] ?? null; } public function getNext(string|WorkflowEtape|FeuilleDeRouteEtape $etape): ?FeuilleDeRouteEtape public function getNext(string|WorkflowEtape|FeuilleDeRouteEtape|null $etape = null, bool $needAllowed = true): ?FeuilleDeRouteEtape { if (!$this->builted) { $this->build(); Loading @@ -121,22 +131,19 @@ class FeuilleDeRoute $etape = $etape->workflowEtape->getCode(); } return null; /** @TODO */ } // Si l'étape n'est pas précisée, on est déjà dans la prochaine $isNext = $etape === null; public function getPrevious(string|WorkflowEtape|FeuilleDeRouteEtape $etape): ?FeuilleDeRouteEtape { if (!$this->builted) { $this->build(); foreach($this->fdr as $code => $wfEtape){ if ($isNext){ if ($wfEtape->atteignable && !$wfEtape->isFranchie()){ if (!$needAllowed || $wfEtape->isAllowed()){ return $wfEtape; } if ($etape instanceof WorkflowEtape) { $etape = $etape->getCode(); } if ($etape instanceof FeuilleDeRouteEtape) { $etape = $etape->workflowEtape->getCode(); }elseif($code === $etape){ $isNext = true; } } return null; /** @TODO */ Loading
module/Workflow/src/Model/FeuilleDeRouteEtape.php +6 Changes for module/Workflow/src/Model/FeuilleDeRouteEtape.php: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -60,6 +60,12 @@ class FeuilleDeRouteEtape public function isFranchie(): bool { return $this->realisation >= $this->objectif; } public function isAllowed(): bool { return true; Loading