Commit b184de59 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Chargement dynamique des tbls

parent b3564fe9
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -86,9 +86,9 @@ class ModuleOptions extends AbstractOptions

        $tableauxBord = [];
        foreach ($options as $tblName => $tblOptions) {
            $tableauBord = new TableauBord();
            $tableauBord = new TableauBord($container);
            $tableauBord->setName($tblName);
            $tableauBord->loadOptions($tblOptions, $container);
            $tableauBord->loadOptions($tblOptions);
            $tableauxBord[$tableauBord->getName()] = $tableauBord;
        }

+28 −12
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ class TableauBord

    protected int $order = 0;

    protected string $processName;

    protected ?ProcessInterface $process = null;

    private float $timingBegin = 0.0;
@@ -35,6 +37,15 @@ class TableauBord



    public function __construct(
        private readonly ContainerInterface $__container,
    )
    {

    }



    public function getName(): ?string
    {
        return $this->name;
@@ -72,6 +83,7 @@ class TableauBord
    }



    public function onAction(string $action, ?int $progress = null, ?int $total = null)
    {
        if (null !== $this->onAction) {
@@ -105,6 +117,19 @@ class TableauBord

    public function getProcess(): ?ProcessInterface
    {
        if (!$this->process) {
            $processName = $this->processName;

            if (!$this->__container->has($processName)) {
                $processName = 'unicaen-tbl.process.' . $processName;
            }
            if (!$this->__containertainer->has($processName)) {
                throw new \Exception('Le process "' . $processName . '" n\'est pas un service reconnu ou accessible via le container');
            }
            /** @var ProcessInterface $process */
            $process       = $this->__container->get($processName);
            $this->process = $process;
        }
        return $this->process;
    }

@@ -146,7 +171,7 @@ class TableauBord



    public function loadOptions(array $options, ContainerInterface $container): self
    public function loadOptions(array $options): self
    {
        if (array_key_exists('name', $options)) {
            $this->setName($options['name']);
@@ -157,16 +182,7 @@ class TableauBord
        }

        if (array_key_exists('process', $options)) {
            $processName = $options['process'] ?? null;
            if (!$container->has($processName)) {
                $processName = 'unicaen-tbl.process.' . $processName;
            }
            if (!$container->has($processName)) {
                throw new \Exception('Le process "' . $processName . '" n\'est pas un service reconnu ou accessible via le container');
            }
            /** @var ProcessInterface $process */
            $process = $container->get($processName);
            $this->setProcess($process);
            $this->processName = $options['process'] ?? null;
        }

        $this->options = $options;