Commit 826c9bc2 authored by lecluse's avatar lecluse
Browse files

Refactoring et optimisation générale

parent fab655e8
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "2e5b200c550fe0380663902466ee4d6e",
"hash": "308cfa4cdcc7d4dd8adddc06573faad5",
"packages": [
{
"name": "bjyoungblood/bjy-authorize",
......@@ -78,16 +78,16 @@
},
{
"name": "doctrine/annotations",
"version": "v1.2.6",
"version": "v1.2.7",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "f4a91702ca3cd2e568c3736aa031ed00c3752af4"
"reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/f4a91702ca3cd2e568c3736aa031ed00c3752af4",
"reference": "f4a91702ca3cd2e568c3736aa031ed00c3752af4",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535",
"reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535",
"shasum": ""
},
"require": {
......@@ -142,20 +142,20 @@
"docblock",
"parser"
],
"time": "2015-06-17 12:21:22"
"time": "2015-08-31 12:32:49"
},
{
"name": "doctrine/cache",
"version": "v1.4.1",
"version": "v1.4.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "c9eadeb743ac6199f7eec423cb9426bc518b7b03"
"reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/c9eadeb743ac6199f7eec423cb9426bc518b7b03",
"reference": "c9eadeb743ac6199f7eec423cb9426bc518b7b03",
"url": "https://api.github.com/repos/doctrine/cache/zipball/8c434000f420ade76a07c64cbe08ca47e5c101ca",
"reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca",
"shasum": ""
},
"require": {
......@@ -212,7 +212,7 @@
"cache",
"caching"
],
"time": "2015-04-15 00:11:59"
"time": "2015-08-31 12:36:41"
},
{
"name": "doctrine/collections",
......@@ -282,16 +282,16 @@
},
{
"name": "doctrine/common",
"version": "v2.5.0",
"version": "v2.5.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/common.git",
"reference": "cd8daf2501e10c63dced7b8b9b905844316ae9d3"
"reference": "0009b8f0d4a917aabc971fb089eba80e872f83f9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/common/zipball/cd8daf2501e10c63dced7b8b9b905844316ae9d3",
"reference": "cd8daf2501e10c63dced7b8b9b905844316ae9d3",
"url": "https://api.github.com/repos/doctrine/common/zipball/0009b8f0d4a917aabc971fb089eba80e872f83f9",
"reference": "0009b8f0d4a917aabc971fb089eba80e872f83f9",
"shasum": ""
},
"require": {
......@@ -351,7 +351,7 @@
"persistence",
"spl"
],
"time": "2015-04-02 19:55:44"
"time": "2015-08-31 13:00:22"
},
{
"name": "doctrine/dbal",
......@@ -507,12 +507,12 @@
"version": "0.9.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/DoctrineORMModule.git",
"url": "git@github.com:doctrine/DoctrineORMModule.git",
"reference": "11cf6a34cd097b4d252a82d198ceed565ee3102c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineORMModule/zipball/11cf6a34cd097b4d252a82d198ceed565ee3102c",
"url": "https://api.github.com/repos/doctrine/DoctrineORMModule/zipball/731ec00a3b5cb9fcf0def3abc42e0ac58f8d0265",
"reference": "11cf6a34cd097b4d252a82d198ceed565ee3102c",
"shasum": ""
},
......@@ -757,16 +757,16 @@
},
{
"name": "doctrine/orm",
"version": "v2.5.0",
"version": "v2.5.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/doctrine2.git",
"reference": "aa80c7d2c55a372f5f9f825f5c66dbda53a6e3fe"
"reference": "e6a83bedbe67579cb0bfb688e982e617943a2945"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/doctrine2/zipball/aa80c7d2c55a372f5f9f825f5c66dbda53a6e3fe",
"reference": "aa80c7d2c55a372f5f9f825f5c66dbda53a6e3fe",
"url": "https://api.github.com/repos/doctrine/doctrine2/zipball/e6a83bedbe67579cb0bfb688e982e617943a2945",
"reference": "e6a83bedbe67579cb0bfb688e982e617943a2945",
"shasum": ""
},
"require": {
......@@ -830,7 +830,7 @@
"database",
"orm"
],
"time": "2015-04-02 20:40:18"
"time": "2015-08-31 12:59:39"
},
{
"name": "jasig/phpcas",
......@@ -4454,6 +4454,60 @@
],
"time": "2015-05-07 14:55:31"
},
{
"name": "zendframework/zend-file",
"version": "2.4.7",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-file.git",
"reference": "eafa689f26fdaaa8569b1cbe927fc5d75ca802b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-file/zipball/eafa689f26fdaaa8569b1cbe927fc5d75ca802b2",
"reference": "eafa689f26fdaaa8569b1cbe927fc5d75ca802b2",
"shasum": ""
},
"require": {
"php": ">=5.3.23",
"zendframework/zend-stdlib": "self.version"
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "dev-master",
"zendframework/zend-filter": "self.version",
"zendframework/zend-i18n": "self.version",
"zendframework/zend-validator": "self.version"
},
"suggest": {
"zendframework/zend-filter": "Zend\\Filter component",
"zendframework/zend-i18n": "Zend\\I18n component",
"zendframework/zend-validator": "Zend\\Validator component"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev",
"dev-develop": "2.5-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\File\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"homepage": "https://github.com/zendframework/zend-file",
"keywords": [
"file",
"zf2"
],
"time": "2015-05-07 14:55:31"
},
{
"name": "zendframework/zend-test",
"version": "2.4.7",
......
......@@ -17,33 +17,11 @@
*/
// Composer autoloading
//if (file_exists('vendor/autoload.php')) {
include 'vendor/autoload.php';
//}
/*
$zf2Path = false;
if (is_dir('vendor/ZF2/library')) {
$zf2Path = 'vendor/ZF2/library';
} elseif (getenv('ZF2_PATH')) { // Support for ZF2_PATH environment variable or git submodule
$zf2Path = getenv('ZF2_PATH');
} elseif (get_cfg_var('zf2_path')) { // Support for zf2_path directive value
$zf2Path = get_cfg_var('zf2_path');
if (file_exists('vendor/autoload.php')) {
include 'vendor/autoload.php';
}
if ($zf2Path) {
if (isset($loader)) {
$loader->add('Zend', $zf2Path);
} else {
include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
Zend\Loader\AutoloaderFactory::factory(array(
'Zend\Loader\StandardAutoloader' => array(
'autoregister_zf' => true
)
));
}
}
*/
if (!class_exists('Zend\Loader\AutoloaderFactory')) {
throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
}
......@@ -124,6 +124,9 @@ class Module implements ConsoleUsageProviderInterface, ConsoleBannerProviderInte
public function getAutoloaderConfig()
{
return [
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
......
......@@ -214,10 +214,7 @@ $main = [
],
'invokables' => [
'validationDl' => 'Application\View\Helper\ValidationDl',
'mailto' => 'Application\View\Helper\Mailto',
'intervenantDl' => 'Application\View\Helper\IntervenantDl',
'adresseDl' => 'Application\View\Helper\AdresseDl',
'elementPedagogiqueDl' => 'Application\View\Helper\OffreFormation\ElementPedagogiqueDl',
'utilisateur' => 'Application\View\Helper\UtilisateurViewHelper',
'fieldsetElementPedagogiqueRecherche' => 'Application\View\Helper\OffreFormation\FieldsetElementPedagogiqueRecherche',
],
],
......
......@@ -58,19 +58,11 @@ return [
'voir' => [
'type' => 'Segment',
'options' => [
'route' => '/voir/:id',
'constraints' => [ 'id' => '[0-9]*' ],
'route' => '/voir/:elementPedagogique',
'constraints' => [ 'elementPedagogique' => '[0-9]*' ],
'defaults' => [ 'action' => 'voir' ],
],
],
'apercevoir' => [
'type' => 'Segment',
'options' => [
'route' => '/apercevoir/:id',
'constraints' => [ 'id' => '[0-9]*' ],
'defaults' => [ 'action' => 'apercevoir' ],
],
],
'ajouter' => [
'type' => 'Segment',
'options' => [
......@@ -391,7 +383,7 @@ return [
'invokables' => [
'EtapeModulateursSaisieForm' => 'Application\View\Helper\OffreFormation\EtapeModulateursSaisieForm',
'ElementModulateursSaisieFieldset' => 'Application\View\Helper\OffreFormation\ElementModulateursSaisieFieldset',
'ElementPedagogique' => 'Application\View\Helper\OffreFormation\ElementPedagogique',
'ElementPedagogique' => 'Application\View\Helper\OffreFormation\ElementPedagogiqueViewHelper',
'Etape' => 'Application\View\Helper\OffreFormation\EtapeViewHelper',
'EtapeCentreCoutForm' => 'Application\View\Helper\OffreFormation\EtapeCentreCoutFormViewHelper',
'ElementCentreCoutFieldset' => 'Application\View\Helper\OffreFormation\ElementCentreCoutFieldsetViewHelper',
......
......@@ -16,47 +16,38 @@ use Application\Exception\DbException;
class ElementPedagogiqueController extends AbstractActionController
{
use \Application\Service\Traits\ElementPedagogiqueAwareTrait,
\Application\Service\Traits\ContextAwareTrait
;
\Application\Service\Traits\ContextAwareTrait;
public function voirAction()
{
$element = $this->context()->mandatory()->elementPedagogiqueFromRoute('id');
$title = "Détails d'un enseignement";
$short = $this->params()->fromQuery('short', false);
$viewModel = new \Zend\View\Model\ViewModel();
$viewModel->setVariables(compact('element', 'title', 'short'));
$element = $this->getEvent()->getParam('elementPedagogique');
$title = "Enseignement";
return $viewModel;
return compact('element', 'title');
}
public function apercevoirAction()
{
$element = $this->context()->mandatory()->elementPedagogiqueFromRoute('id');
$title = "Aperçu d'un enseignement";
$short = $this->params()->fromQuery('short', false);
$viewModel = new \Zend\View\Model\ViewModel();
$viewModel->setVariables(compact('element', 'title', 'short'));
return $viewModel;
}
public function ajouterAction()
{
return $this->saisirAction();
}
public function modifierAction()
{
return $this->saisirAction();
}
protected function saisirAction()
{
$etape = $this->context()->mandatory()->etapeFromRoute(); /* @var $etape \Application\Entity\Db\Etape */
$etape = $this->context()->mandatory()->etapeFromRoute();
/* @var $etape \Application\Entity\Db\Etape */
$id = $this->params()->fromRoute('id');
$service = $this->getServiceElementPedagogique();
$title = $id ? "Modification d'un enseignement" : "Création d'un enseignement";
......@@ -68,11 +59,11 @@ class ElementPedagogiqueController extends AbstractActionController
if ($id) {
$entity = $service->getRepo()->find($id);
$form->bind($entity);
}
else {
$entity = $service->newEntity(); /* @var $entity \Application\Entity\Db\ElementPedagogique */
} else {
$entity = $service->newEntity();
/* @var $entity \Application\Entity\Db\ElementPedagogique */
$entity->setEtape($etape)
->setStructure($etape->getStructure());
->setStructure($etape->getStructure());
$form->setObject($entity);
}
......@@ -85,8 +76,7 @@ class ElementPedagogiqueController extends AbstractActionController
try {
$service->save($entity);
$form->get('id')->setValue($entity->getId()); // transmet le nouvel ID
}
catch (\Exception $e) {
} catch (\Exception $e) {
$e = DbException::translate($e);
$errors[] = $e->getMessage();
}
......@@ -95,23 +85,25 @@ class ElementPedagogiqueController extends AbstractActionController
$viewModel = new \Zend\View\Model\ViewModel();
$viewModel->setTemplate('application/offre-formation/element-pedagogique/saisir')
->setVariables(compact('form', 'title', 'errors'));
->setVariables(compact('form', 'title', 'errors'));
return $viewModel;
}
public function supprimerAction()
{
$id = $this->params()->fromRoute('id', 0);
if (!($id = $this->params()->fromRoute('id'))){
if (!($id = $this->params()->fromRoute('id'))) {
throw new \Common\Exception\RuntimeException('L\'identifiant n\'est pas bon ou n\'a pas été fourni');
}
$service = $this->getServiceElementPedagogique();
$entity = $service->getRepo()->find($id);
$title = "Suppression d'enseignement";
$form = new \Application\Form\Supprimer('suppr');
$errors = [];
$service = $this->getServiceElementPedagogique();
$entity = $service->getRepo()->find($id);
$title = "Suppression d'enseignement";
$form = new \Application\Form\Supprimer('suppr');
$errors = [];
$form->setAttribute('action', $this->url()->fromRoute(null, [], [], true));
$service->canAdd(true);
......@@ -119,14 +111,17 @@ class ElementPedagogiqueController extends AbstractActionController
if ($this->getRequest()->isPost()) {
try {
$service->delete($entity);
}catch(\Exception $e){
$e = DbException::translate($e);
} catch (\Exception $e) {
$e = DbException::translate($e);
$errors[] = $e->getMessage();
}
}
return compact('entity', 'title', 'form', 'errors');
}
/**
* Action pour rechercher des éléments pédagogiques.
*
......@@ -147,7 +142,7 @@ class ElementPedagogiqueController extends AbstractActionController
{
$this->em()->getFilters()->enable('annee')->init(
[
'Application\Entity\Db\ElementPedagogique'
'Application\Entity\Db\ElementPedagogique',
],
$this->getServiceContext()->getAnnee()
);
......@@ -156,14 +151,14 @@ class ElementPedagogiqueController extends AbstractActionController
$niveau = $this->context()->niveauFromQuery();
$etape = $this->context()->etapeFromQuery();
$element = $this->context()->elementPedagogiqueFromQuery();
$term = $this->params()->fromQuery('term');
$term = $this->params()->fromQuery('term');
if (! $etape && !$term) {
if (!$etape && !$term) {
exit;
}
// respect des filtres éventuels spécifiés en GET ou sinon en session
$params = [];
$params = [];
$params['structure'] = $structure;
$params['niveau'] = $niveau;
$params['etape'] = $etape;
......@@ -172,11 +167,11 @@ class ElementPedagogiqueController extends AbstractActionController
$params['limit'] = $limit = 101;
// fetch
$found = $this->getServiceElementPedagogique()->getSearchResultByTerm($params);
$found = $this->getServiceElementPedagogique()->getSearchResultByTerm($params);
$result = [];
foreach ($found as $item) {
if ($item['NB_CH'] > 1){
if ($item['NB_CH'] > 1) {
$item['LIBELLE_ETAPE'] = 'Enseignement commun à plusieurs parcours';
}
......@@ -188,7 +183,7 @@ class ElementPedagogiqueController extends AbstractActionController
$extra .= sprintf('<span class="element-rech etape" title="%s">%s</span>', "Formation", $item['LIBELLE_ETAPE']);
}
$extra .= "Année" !== $item['LIBELLE_PE'] ? sprintf('<span class="element-rech periode" title="%s">%s</span>', "Période", $item['LIBELLE_PE']) : null;
$template = sprintf('<span class="element-rech extra">{extra}</span><span class="element-rech element" title="%s">{label}</span>', "Enseignement");
$template = sprintf('<span class="element-rech extra">{extra}</span><span class="element-rech element" title="%s">{label}</span>', "Enseignement");
$result[$item['ID']] = [
'id' => $item['ID'],
'label' => $item['SOURCE_CODE'] . ' ' . $item['LIBELLE'],
......@@ -202,19 +197,24 @@ class ElementPedagogiqueController extends AbstractActionController
return new \Zend\View\Model\JsonModel($result);
}
public function getPeriodeAction()
{
$elementPedagogique = $this->context()->elementPedagogiqueFromRoute();
$code = null;
if ($elementPedagogique){
if ($periode = $elementPedagogique->getPeriode()){
$code = null;
if ($elementPedagogique) {
if ($periode = $elementPedagogique->getPeriode()) {
$code = $periode->getCode();
}
}
$result = ['periode' => [ 'code' => $code ] ];
$result = ['periode' => ['code' => $code]];
return new \Zend\View\Model\JsonModel($result);
}
/**
* Retourne le formulaire d'ajout/modif d'ElementPedagogique.
*
......
<?php
namespace Application\Entity\Db;
use Common\Constants;
use UnicaenApp\Entity\HistoriqueAwareInterface;
use UnicaenApp\Entity\HistoriqueAwareTrait;
......@@ -497,24 +498,16 @@ class AdresseIntervenant implements HistoriqueAwareInterface
*/
public function __toString()
{
$part1 = [];
$part1[] = $this->getNoVoie();
$part1[] = $this->getNomVoie();
$part1[] = $this->getBatiment();
$part1[] = $this->getMentionComplementaire();
$part1 = implode(', ', array_filter($part1));
$part2 = [];
$part2[] = $this->getLocalite();
$part2[] = $this->getCodePostal();
$part2[] = $this->getVille();
$part2[] = $this->getPaysLibelle();
$part2 = implode(', ', array_filter($part2));
$parts = [];
$parts[] = $part1;
$parts[] = $part2;
return implode(PHP_EOL, array_filter($parts));
$pays = $this->getPaysLibelle();
if (strtoupper($pays) == Constants::ADRESSE_PAYS_DEFAULT) $pays = '';
return implode( "\n", array_filter([
trim( $this->getNoVoie().' '.$this->getNomVoie() ),
trim( $this->getBatiment() ),
trim( $this->getMentionComplementaire() ),
trim( $this->getLocalite() ),
trim( $this->getCodePostal().' '.$this->getVille() ),
trim( $pays )
]));
}
}
<?php
namespace Application\Entity\DB;
namespace Application\Entity\Db;
trait ServiceAPayerTrait
{
......
<?php
namespace Application\View\Helper;
use Application\Entity\Db\AdresseIntervenant;
/**
* Description of AdresseDl
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class AdresseDl extends AbstractDl
{
/**
* @var AdresseIntervenant
*/
protected $entity;
/**
* @var bool
*/
protected $condensed;
/**
*
* @param mixed $entity
* @param bool $horizontal
* @param bool $condensed
* @return self
*/
public function __invoke($entity = null, $horizontal = false, $condensed = false)
{
parent::__invoke($entity, $horizontal);
$this->condensed = $condensed;
return $this;
}