Commit d05e331f authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Début de la gestion de la page des informations

parent 7a00ad6c
Loading
Loading
Loading
Loading
+2
Changes for module/Application/config/module.config.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -251,6 +251,8 @@ return array(
            '061_uploader' => "/js/jquery.iframe-transport.js",
            '062_uploader' => "/js/jquery.fileupload.js",
            '063_uploader' => "/js/unicaen.uploader.widget.js",
            '100_' => 'js/tinymce/js/tinymce/tinymce.js',
            '101_' => 'js/form_fiche.js',
        ],
        'inline_scripts'        => [
        ],
+x+133
Changes for module/Application/config/others/information.config.php: 133 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

use Application\Controller\Factory\InformationControllerFactory;
use Application\Controller\InformationController;
use Application\Service\Information\InformationService;
use Application\Service\Information\InformationServiceFactory;
use UnicaenAuth\Guard\PrivilegeController;
use Zend\Mvc\Router\Http\Literal;
use Zend\Mvc\Router\Http\Segment;

return [
    'bjyauthorize'    => [
        'guards' => [
            PrivilegeController::class => [
                [
                    'controller' => InformationController::class,
                    'action'     => [
                        'index',
                    ],
//                    'privileges' => [
//                        StructurePrivileges::STRUCTURE_CONSULTATION_TOUTES_STRUCTURES,
//                        StructurePrivileges::STRUCTURE_CONSULTATION_SES_STRUCTURES,
//                    ],
                ],
                [
                    'controller' => InformationController::class,
                    'action'     => [
                        'ajouter',
                        'supprimer',
                    ],
//                    'privileges' => [
//                        StructurePrivileges::STRUCTURE_MODIFICATION_TOUTES_STRUCTURES,
//                        StructurePrivileges::STRUCTURE_MODIFICATION_SES_STRUCTURES,
//                        StructurePrivileges::STRUCTURE_CREATION_ED,
//                    ],
                ],
                [
                    'controller' => InformationController::class,
                    'action'     => [
                        'modifier',
                    ],
//                    'privileges' => [
//                        StructurePrivileges::STRUCTURE_MODIFICATION_TOUTES_STRUCTURES,
//                        StructurePrivileges::STRUCTURE_MODIFICATION_SES_STRUCTURES,
//                    ],
                ],
                [
                    'controller' => InformationController::class,
                    'action'     => [
                        'afficher',
                    ],
                    'roles' => [],
                ],
            ],
        ],
    ],
    'router'          => [
        'routes' => [
            'informations' => [
                'type'          => Literal::class,
                'options'       => [
                    'route'    => '/informations',
                    'defaults' => [
                        'controller'    => InformationController::class,
                        'action'        => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes'  => [
                    'afficher' => [
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/afficher/:id',
                            'defaults'    => [
                                'action' => 'afficher',
                            ],
                        ],
                    ],
                    'ajouter' => [
                        'type'          => Literal::class,
                        'options'       => [
                            'route'       => '/ajouter',
                            'defaults'    => [
                                'action' => 'ajouter',
                            ],
                        ],
                    ],
                    'supprimer' => [
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/supprimer/:id',
                            'defaults'    => [
                                'action' => 'supprimer',
                            ],
                        ],
                    ],
                    'modifier' => [
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/modifier/:id',
                            'defaults'    => [
                                'action' => 'modifier',
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],

    'service_manager' => [
        'factories' => [
            InformationService::class => InformationServiceFactory::class
        ],
    ],
    'controllers'     => [
        'factories' => [
            InformationController::class => InformationControllerFactory::class
        ],
    ],
    'form_elements'   => [
        'factories' => [
        ],
    ],
    'hydrators' => [
        'factories' => [
        ]
    ],
    'view_helpers' => [
        'invokables' => [
        ],
    ],
];
+22
Changes for module/Application/src/Application/Controller/Factory/InformationControllerFactory.php: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Controller\Factory;

use Application\Controller\InformationController;
use Application\Service\Information\InformationService;
use Zend\Mvc\Controller\ControllerManager;

class InformationControllerFactory {

    public function __invoke(ControllerManager $controllerManager)
    {
        /**
         * @var InformationService $infromationService
         */
        $infromationService = $controllerManager->getServiceLocator()->get(InformationService::class);

        $controller = new InformationController();
        $controller->setInformationService($infromationService);
        return $controller;
    }
}
 No newline at end of file
+44
Changes for module/Application/src/Application/Controller/InformationController.php: 44 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Controller;

use Application\Service\Information\InformationServiceAwareTrait;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class InformationController extends AbstractActionController {
    use InformationServiceAwareTrait;

    public function indexAction()
    {
        $informations = $this->getInformationService()->getInformations();
        return new ViewModel([
            'informations' => $informations,
        ]);
    }

    public function afficherAction()
    {
        $informationId  = $this->params()->fromRoute('id');
        $information    = $this->getInformationService()->getInformation($informationId);

        return new ViewModel([
            'information' => $information,
        ]);
    }

    public function ajouterAction()
    {
        return new ViewModel([]);
    }

    public function modifierAction()
    {
        return new ViewModel([]);
    }

    public function supprimerAction()
    {
        return new ViewModel([]);
    }
}
+70
Changes for module/Application/src/Application/Entity/Db/Information.php: 70 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Application\Entity\Db;

use UnicaenApp\Entity\HistoriqueAwareInterface;
use UnicaenApp\Entity\HistoriqueAwareTrait;

/**
 * --- Class Information ---
 *
 * @var integer  $id                    un identifiant unique servant de clef
 * @var string   $titre                 Le titre de la page
 * @var string   $contenu               Le contenu de la page
 */
class Information implements HistoriqueAwareInterface
{
    use HistoriqueAwareTrait;

    /** @var integer */
    private $id;
    /** @var string */
    private $titre;
    /** @var string */
    private $contenu;

    /**
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }


    /**
     * @return string
     */
    public function getTitre()
    {
        return $this->titre;
    }

    /**
     * @param string $titre
     * @return Information
     */
    public function setTitre($titre)
    {
        $this->titre = $titre;
        return $this;
    }

    /**
     * @return string
     */
    public function getContenu()
    {
        return $this->contenu;
    }

    /**
     * @param string $contenu
     * @return Information
     */
    public function setContenu($contenu)
    {
        $this->contenu = $contenu;
        return $this;
    }
}
 No newline at end of file
Loading