Commit 1d7a4cbb authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Modularisation des indicateurs

Mise en place d'une config simplifiée pour les petits modules
parent fe73ff68
Loading
Loading
Loading
Loading
+2 −1
Changes for composer.json: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -24,7 +24,8 @@
    "autoload": {
        "psr-4": {
            "Application\\": "module/Application/src/",
            "Plafond\\": "module/Plafond/src/"
            "Plafond\\": "module/Plafond/src/",
            "Indicateur\\": "module/Indicateur/src/"
        }
    },
    "require-dev" : {
+1 −0
Changes for config/application.config.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ class AppConfig
            'UnicaenTbl',
            'Application',
            'Plafond',
            'Indicateur',
        ];

        if (!self::inConsole()) {
+14 −1
Changes for module/Application/Module.php: 14 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ namespace Application;

use Application\Service\ContextService;
use Psr\Container\ContainerInterface;
use Zend\ModuleManager\ModuleManager;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Zend\ModuleManager\Feature\ConsoleUsageProviderInterface;
@@ -27,6 +28,9 @@ include_once(__DIR__ . '/src/Application/functions.php');

class Module implements ConsoleUsageProviderInterface, ConsoleBannerProviderInterface
{
    private $modules = [];



    public function onBootstrap(MvcEvent $e)
    {
@@ -107,14 +111,23 @@ class Module implements ConsoleUsageProviderInterface, ConsoleBannerProviderInte

    private function getEntityService(ContainerInterface $container, $paramName)
    {
        if (empty($this->modules)) {
            $moduleManager = $container->get('ModuleManager');
            /* @var $moduleManager ModuleManager */

            $this->modules = $moduleManager->getModules();
        }

        if ('typeAgrementCode' === $paramName) {
            $paramName = 'typeAgrement';
        }

        $serviceName = 'Application\\Service\\' . ucfirst($paramName) . 'Service';
        foreach ($this->modules as $module) {
            $serviceName = $module . '\\Service\\' . ucfirst($paramName) . 'Service';
            if ($container->has($serviceName)) {
                return $container->get($serviceName);
            }
        }

        return null;
    }
+907 −629

File changed.

Preview size limit exceeded, changes collapsed.

+0 −217
Changes for module/Application/config/indicateur.config.php: 0 added lines, 217 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application;

use Application\Provider\Privilege\Privileges;
use UnicaenAuth\Guard\PrivilegeController;

return [
    'router' => [
        'routes' => [
            'indicateur' => [
                'type'          => 'Literal',
                'options'       => [
                    'route'    => '/gestion/indicateur',
                    'defaults' => [
                        'controller' => 'Application\Controller\Indicateur',
                        'action'     => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes'  => [
                    'result'                  => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'       => '/result/:indicateur[/structure/:structure]',
                            'constraints' => [
                                'indicateur' => '[0-9]*',
                                'structure'  => '[0-9]*',
                            ],
                            'defaults'    => [
                                'action' => 'result',
                            ],
                        ],
                    ],
                    'abonner'                 => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'       => '/abonner/:indicateur',
                            'constraints' => [
                                'indicateur' => '[0-9]*',
                            ],
                            'defaults'    => [
                                'action' => 'abonner',
                            ],
                        ],
                    ],
                    'abonnements'             => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'    => '/abonnements',
                            'defaults' => [
                                'action' => 'abonnements',
                            ],
                        ],
                    ],
                    'envoi-mail-intervenants' => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'       => '/envoi-mail-intervenants/:indicateur',
                            'constraints' => [
                                'indicateur' => '[0-9]*',
                            ],
                            'defaults'    => [
                                'action' => 'envoi-mail-intervenants',
                            ],
                        ],
                    ],
                    'depassement-charges'     => [
                        'type'         => 'Segment',
                        'options'      => [
                            'route'       => '/depassement-charges/:intervenant',
                            'defaults'    => [
                                'action' => 'depassement-charges',
                            ],
                        ],
                        'child_routes' => [
                            'prevu'   => [
                                'type'         => 'Literal',
                                'options'      => [
                                    'route'    => '/prevu',
                                    'defaults' => [
                                        'type-volume-horaire-code' => 'PREVU',
                                    ],
                                ],
                                'child_routes' => [
                                    's1' => [
                                        'type'    => 'Literal',
                                        'options' => [
                                            'route'    => '/s1',
                                            'defaults' => [
                                                'periode-code' => 'S1',
                                            ],
                                        ],
                                    ],
                                    's2' => [
                                        'type'    => 'Literal',
                                        'options' => [
                                            'route'    => '/s2',
                                            'defaults' => [
                                                'periode-code' => 'S2',
                                            ],
                                        ],
                                    ],
                                ],
                            ],
                            'realise' => [
                                'type'         => 'Literal',
                                'options'      => [
                                    'route'    => '/realise',
                                    'defaults' => [
                                        'type-volume-horaire-code' => 'REALISE',
                                    ],
                                ],
                                'child_routes' => [
                                    's1' => [
                                        'type'    => 'Literal',
                                        'options' => [
                                            'route'    => '/s1',
                                            'defaults' => [
                                                'periode-code' => 'S1',
                                            ],
                                        ],
                                    ],
                                    's2' => [
                                        'type'    => 'Literal',
                                        'options' => [
                                            'route'    => '/s2',
                                            'defaults' => [
                                                'periode-code' => 'S2',
                                            ],
                                        ],
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'console' => [
        'router' => [
            'routes' => [
                'notifier-indicateurs' => [
                    'options' => [
                        'route'    => 'notifier indicateurs [--force]',
                        'defaults' => [
                            'controller' => 'Application\Controller\Indicateur',
                            'action'     => 'envoi-notifications',
                        ],
                    ],
                ],
            ],
        ],
    ],

    'navigation' => [
        'default' => [
            'home' => [
                'pages' => [
                    'gestion' => [
                        'pages' => [
                            'indicateurs' => [
                                'label'        => "Indicateurs",
                                'icon'         => 'fa fa-line-chart',
                                'title'        => "Indicateurs",
                                'route'        => 'indicateur',
                                'resource'     => PrivilegeController::getResourceId('Application\Controller\Indicateur', 'index'),
                                'order'        => 10,
                                'border-color' => '#217DD8',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'bjyauthorize' => [
        'guards' => [
            PrivilegeController::class => [
                [
                    'controller' => 'Application\Controller\Indicateur',
                    'action'     => ['index', 'result', 'abonnements', 'depassement-charges'],
                    'privileges' => [Privileges::INDICATEUR_VISUALISATION],
                ],
                [
                    'controller' => 'Application\Controller\Indicateur',
                    'action'     => ['abonner'],
                    'privileges' => [Privileges::INDICATEUR_ABONNEMENT],
                ],
                [
                    'controller' => 'Application\Controller\Indicateur',
                    'action'     => ['envoi-mail-intervenants'],
                    'privileges' => [Privileges::INDICATEUR_ENVOI_MAIL_INTERVENANTS],
                ],
            ],
        ],
    ],

    'controllers' => [
        'factories' => [
            'Application\Controller\Indicateur' => Controller\Factory\IndicateurControllerFactory::class,
        ],
    ],

    'service_manager' => [
        'invokables' => [
            Service\IndicateurService::class             => Service\IndicateurService::class,
            Service\NotificationIndicateurService::class => Service\NotificationIndicateurService::class,
        ],
        'factories'  => [
            Processus\IndicateurProcessus::class => Processus\Factory\IndicateurProcessusFactory::class,
        ],
    ],
];
 No newline at end of file
Loading