Commit 7ad398c7 authored by lecluse's avatar lecluse
Browse files

Nouveau Méga-refactoring : utilisation des nouveaux traits et interfaces d'entités.

Optimisation massive de la gestion des utilisateurs en vue d'une intégration de la gestion des privilèges à UnicaenAuth
parent e9ccb7ae
......@@ -2,10 +2,10 @@
namespace Application\Acl;
use Application\Interfaces\StructureAwareInterface;
use Application\Traits\StructureAwareTrait;
use Application\Interfaces\PersonnelAwareInterface;
use Application\Traits\PersonnelAwareTrait;
use Application\Entity\Db\Interfaces\StructureAwareInterface;
use Application\Entity\Db\Traits\StructureAwareTrait;
use Application\Entity\Db\Interfaces\PersonnelAwareInterface;
use Application\Entity\Db\Traits\PersonnelAwareTrait;
/**
* Rôle père de tous les rôles "administrateur".
......
......@@ -2,10 +2,10 @@
namespace Application\Acl;
use Application\Interfaces\StructureAwareInterface;
use Application\Traits\StructureAwareTrait;
use Application\Interfaces\PersonnelAwareInterface;
use Application\Traits\PersonnelAwareTrait;
use Application\Entity\Db\Interfaces\StructureAwareInterface;
use Application\Entity\Db\Traits\StructureAwareTrait;
use Application\Entity\Db\Interfaces\PersonnelAwareInterface;
use Application\Entity\Db\Traits\PersonnelAwareTrait;
/**
* Rôle père de tous les rôles "composante".
......
......@@ -2,9 +2,8 @@
namespace Application\Acl;
use UnicaenAuth\Acl\NamedRole;
use Application\Interfaces\PersonnelAwareInterface;
use Application\Traits\PersonnelAwareTrait;
use Application\Entity\Db\Interfaces\PersonnelAwareInterface;
use Application\Entity\Db\Traits\PersonnelAwareTrait;
/**
* Rôle père de tous les rôles "composante".
......
......@@ -2,9 +2,8 @@
namespace Application\Acl;
use UnicaenAuth\Acl\NamedRole;
use Application\Interfaces\PersonnelAwareInterface;
use Application\Traits\PersonnelAwareTrait;
use Application\Entity\Db\Interfaces\PersonnelAwareInterface;
use Application\Entity\Db\Traits\PersonnelAwareTrait;
/**
* Rôle père de tous les rôles "composante".
......
......@@ -12,9 +12,9 @@ use Application\Entity\Db\Role as DbRole;
*/
class Role extends NamedRole
{
use \Application\Traits\StructureAwareTrait,
\Application\Traits\PersonnelAwareTrait,
\Application\Traits\IntervenantAwareTrait;
use \Application\Entity\Db\Traits\StructureAwareTrait,
\Application\Entity\Db\Traits\PersonnelAwareTrait,
\Application\Entity\Db\Traits\IntervenantAwareTrait;
const ROLE_ID = 'role';
......
......@@ -240,7 +240,7 @@ class AgrementController extends AbstractActionController implements WorkflowInt
* Il y a un seul Conseil Academique pour toutes les structures d'enseignement
*/
elseif ($this->typeAgrement->getCode() === TypeAgrement::CODE_CONSEIL_ACADEMIQUE) {
$structure = $this->intervenant->getStructure()->getParenteNiv2();
$structure = $this->intervenant->getStructure();
}
else {
throw new LogicException("Type d'agrément inattendu!");
......
......@@ -4,8 +4,17 @@ namespace Application\Controller;
use Application\Acl\ComposanteRole;
use Application\Entity\Db\Intervenant;
use Application\Entity\Db\Service;
use Application\Entity\Db\TypeContrat;
use Application\Entity\Db\Validation;
use Application\Entity\Db\VolumeHoraire;
use Application\Service\Traits\ContratAwareTrait;
use Application\Service\Traits\EtatVolumeHoraireAwareTrait;
use Application\Service\Traits\ServiceServiceAwareTrait;
use Application\Service\Traits\TypeVolumeHoraireAwareTrait;
use Application\Service\Traits\ContextAwareTrait;
use Common\Constants;
use UnicaenApp\Controller\Plugin\Upload\UploaderPlugin;
use UnicaenApp\Exporter\Pdf;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
......@@ -20,15 +29,19 @@ use BjyAuthorize\Exception\UnAuthorizedException;
/**
* Description of ContratController
*
* @method Application\Controller\Plugin\Context context()
* @method Application\Controller\Plugin\Upload\UploadPlugin uploader()
* @method \Application\Controller\Plugin\Context context()
* @method UploaderPlugin uploader()
* @method \Doctrine\ORM\EntityManager em()
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class ContratController extends AbstractActionController
{
use \Application\Service\Traits\ContextAwareTrait;
use ContextAwareTrait;
use ContratAwareTrait;
use ServiceServiceAwareTrait;
use TypeVolumeHoraireAwareTrait;
use EtatVolumeHoraireAwareTrait;
/**
* @var Contrat
......@@ -43,11 +56,11 @@ class ContratController extends AbstractActionController
protected function initFilters()
{
$this->em()->getFilters()->enable('historique')->init([
'Application\Entity\Db\Contrat',
'Application\Entity\Db\TypeContrat',
'Application\Entity\Db\Service',
'Application\Entity\Db\VolumeHoraire',
'Application\Entity\Db\Validation',
Contrat::class,
TypeContrat::class,
Service::class,
VolumeHoraire::class,
Validation::class,
]);
}
......@@ -60,12 +73,8 @@ class ContratController extends AbstractActionController
{
$role = $this->getServiceContext()->getSelectedIdentityRole();
if ($role instanceof IntervenantRole) {
$intervenant = $role->getIntervenant();
}
else {
$intervenant = $this->context()->mandatory()->intervenantFromRoute();
}
$intervenant = $role->getIntervenant() ?: $this->context()->mandatory()->intervenantFromRoute();
/* @var $intervenant Intervenant */
if ($intervenant->estPermanent()) {
throw new \Common\Exception\MessageException("Les intervenants permanents n'ont pas de contrat.");
......@@ -728,44 +737,9 @@ class ContratController extends AbstractActionController
{
if (null === $this->structure) {
$role = $this->getServiceContext()->getSelectedIdentityRole();
// if (!$role instanceof \Application\Interfaces\StructureAwareInterface) {
// throw new LogicException("Rôle courant inattendu.");
// }
$this->structure = $role->getStructure();
}
return $this->structure;
}
/**
* @return \Application\Service\Contrat
*/
private function getServiceContrat()
{
return $this->getServiceLocator()->get('ApplicationContrat');
}
/**
* @return \Application\Service\ServiceService
*/
private function getServiceService()
{
return $this->getServiceLocator()->get('ApplicationService');
}
/**
* @return \Application\Service\TypeVolumeHoraire
*/
private function getServiceTypeVolumeHoraire()
{
return $this->getServiceLocator()->get('ApplicationTypeVolumeHoraire');
}
/**
* @return \Application\Service\EtatVolumeHoraire
*/
private function getServiceEtatVolumeHoraire()
{
return $this->getServiceLocator()->get('ApplicationEtatVolumeHoraire');
}
}
......@@ -244,12 +244,6 @@ class IndicateurController extends AbstractActionController
private function getStructure()
{
$role = $this->getServiceContext()->getSelectedIdentityRole();
// if ($role instanceof \Application\Interfaces\StructureAwareInterface) {
// return $role->getStructure();
// }
//
// return null;
return $role->getStructure();
}
......
......@@ -215,7 +215,7 @@ class PaiementController extends AbstractActionController
$role = $this->getServiceContext()->getSelectedIdentityRole();
$options = [];
if ($role instanceof \Application\Interfaces\StructureAwareInterface && $role->getStructure()) {
if ($role->getStructure()) {
$options['composante'] = $role->getStructure();
}
......
......@@ -208,17 +208,4 @@ class Etablissement implements HistoriqueAwareInterface
return (string)$this->getLibelle();
}
/**
* Get source id
*
* @return integer
* @see \Application\Entity\Db\Source
*/
public function getSourceToString()
{
return $this->getSource()->getLibelle();
}
}
......@@ -1515,19 +1515,6 @@ class Intervenant implements IntervenantInterface, HistoriqueAwareInterface, Res
/**
* Get source id
*
* @return integer
* @see \Application\Entity\Db\Source
*/
public function getSourceToString()
{
return $this->getSource()->getLibelle();
}
/**
* Retourne la représentation littérale de cet objet.
*
......
......@@ -76,14 +76,6 @@ interface IntervenantInterface
*/
public function getAffectationsToString();
/**
* Get source id
*
* @return integer
* @see \Application\Entity\Db\Source
*/
public function getSourceToString();
/**
* Get sourceCode
*
......
......@@ -8,7 +8,6 @@
<index name="IDX_2BC329057E9E2204" columns="HISTO_DESTRUCTEUR_ID"/>
<index name="IDX_2BC3290563F06898" columns="HISTO_MODIFICATEUR_ID"/>
<index name="IDX_2BC32905E9B3446E" columns="SOURCE_ID"/>
<index name="IDX_2BC329053C7479AE" columns="STRUCTURE_NIV2_ID"/>
<index name="IDX_2BC32905C2443469" columns="TYPE_ID"/>
</indexes>
<unique-constraints>
......@@ -30,11 +29,6 @@
<join-column name="SOURCE_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="structureNiv2" target-entity="Application\Entity\Db\Structure">
<join-columns>
<join-column name="STRUCTURE_NIV2_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="type" target-entity="Application\Entity\Db\TypeStructure">
<join-columns>
<join-column name="TYPE_ID" referenced-column-name="ID"/>
......
......@@ -64,11 +64,6 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface
*/
protected $parente;
/**
* @var \Application\Entity\Db\Structure
*/
protected $structureNiv2;
/**
* @var \Doctrine\Common\Collections\Collection
*/
......@@ -90,7 +85,6 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface
function __construct()
{
$this->structureNiv2 = new ArrayCollection;
$this->elementPedagogique = new ArrayCollection;
$this->centreCout = new ArrayCollection;
$this->miseEnPaiementIntervenantStructure = new ArrayCollection;
......@@ -362,34 +356,6 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface
/**
* Set structureNiv2
*
* @param \Application\Entity\Db\Structure $structureNiv2
*
* @return Structure
*/
public function setParenteNiv2(\Application\Entity\Db\Structure $structureNiv2 = null)
{
$this->structureNiv2 = $structureNiv2;
return $this;
}
/**
* Get structureNiv2
*
* @return \Application\Entity\Db\Structure
*/
public function getParenteNiv2()
{
return $this->structureNiv2;
}
/**
* Add elementPedagogique
*
......@@ -494,52 +460,6 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface
/**
* Get source id
*
* @return integer
* @see \Application\Entity\Db\Source
*/
public function getSourceToString()
{
return $this->getSource()->getLibelle();
}
/**
* Teste si cette structure est une structure fille de la structure de niveau 2 spécifiée.
*
* @param \Application\Entity\Db\Structure $structureDeNiv2
*
* @return bool
*/
public function estFilleDeLaStructureDeNiv2(\Application\Entity\Db\Structure $structureDeNiv2)
{
return $this->getParenteNiv2()->getId() === $structureDeNiv2->getId();
}
/**
* @since PHP 5.6.0
* This method is called by var_dump() when dumping an object to get the properties that should be shown.
* If the method isn't defined on an object, then all public, protected and private properties will be shown.
*
* @return array
* @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.debuginfo
*/
function __debugInfo()
{
return [
'id' => $this->id,
'libelleCourt' => $this->libelleCourt,
'historisee' => !$this->estNonHistorise(),
];
}
/**
* Returns the string identifier of the Resource
*
......
......@@ -3,8 +3,8 @@
namespace Application\Entity;
use Application\Entity\Db\ServiceAPayerInterface;
use Application\Interfaces\ServiceAPayerAwareInterface;
use Application\Traits\ServiceAPayerAwareTrait;
use Application\Entity\Db\Interfaces\ServiceAPayerAwareInterface;
use Application\Entity\Db\Traits\ServiceAPayerAwareTrait;
use Application\Entity\Db\Periode;
/**
......
......@@ -15,9 +15,9 @@ use Application\Entity\Db\MiseEnPaiement;
class MiseEnPaiementRecherche
{
use \Application\Traits\StructureAwareTrait,
\Application\Traits\PeriodeAwareTrait,
\Application\Traits\TypeIntervenantAwareTrait;
use \Application\Entity\Db\Traits\StructureAwareTrait;
use \Application\Entity\Db\Traits\PeriodeAwareTrait;
use \Application\Entity\Db\Traits\TypeIntervenantAwareTrait;
/**
* etat
......
......@@ -2,13 +2,13 @@
namespace Application\Entity\Service;
use Application\Interfaces\TypeIntervenantAwareInterface; use Application\Traits\TypeIntervenantAwareTrait;
use Application\Interfaces\IntervenantAwareInterface; use Application\Traits\IntervenantAwareTrait;
use Application\Interfaces\NiveauEtapeAwareInterface; use Application\Traits\NiveauEtapeAwareTrait;
use Application\Interfaces\EtapeAwareInterface; use Application\Traits\EtapeAwareTrait;
use Application\Interfaces\ElementPedagogiqueAwareInterface; use Application\Traits\ElementPedagogiqueAwareTrait;
use Application\Interfaces\TypeVolumeHoraireAwareInterface; use Application\Traits\TypeVolumeHoraireAwareTrait;
use Application\Interfaces\EtatVolumeHoraireAwareInterface; use Application\Traits\EtatVolumeHoraireAwareTrait;
use Application\Entity\Db\Interfaces\TypeIntervenantAwareInterface; use Application\Entity\Db\Traits\TypeIntervenantAwareTrait;
use Application\Entity\Db\Interfaces\IntervenantAwareInterface; use Application\Entity\Db\Traits\IntervenantAwareTrait;
use Application\Interfaces\NiveauEtapeAwareInterface; use Application\Traits\NiveauEtapeAwareTrait;
use Application\Entity\Db\Interfaces\EtapeAwareInterface; use Application\Entity\Db\Traits\EtapeAwareTrait;
use Application\Entity\Db\Interfaces\ElementPedagogiqueAwareInterface; use Application\Entity\Db\Traits\ElementPedagogiqueAwareTrait;
use Application\Entity\Db\Interfaces\TypeVolumeHoraireAwareInterface; use Application\Entity\Db\Traits\TypeVolumeHoraireAwareTrait;
use Application\Entity\Db\Interfaces\EtatVolumeHoraireAwareInterface; use Application\Entity\Db\Traits\EtatVolumeHoraireAwareTrait;
use Application\Entity\Db\Structure;
/**
......
......@@ -15,8 +15,8 @@ use UnicaenApp\Hydrator\Strategy\DateStrategy;
*/
class Saisie extends Form implements InputFilterProviderInterface
{
use \Application\Traits\IntervenantAwareTrait;
use \Application\Traits\TypeAgrementAwareTrait;
use \Application\Entity\Db\Traits\IntervenantAwareTrait;
use \Application\Entity\Db\Traits\TypeAgrementAwareTrait;
public function init()
{
......
......@@ -14,7 +14,7 @@ use Zend\Stdlib\Hydrator\ClassMethods;
*/
class ContratRetour extends Form implements InputFilterProviderInterface
{
use \Application\Traits\ContratAwareTrait;
use \Application\Entity\Db\Traits\ContratAwareTrait;
public function init()
{
......
......@@ -15,7 +15,7 @@ use Zend\Validator\NotEmpty;
*/
class ContratValidation extends Form implements InputFilterProviderInterface
{
use \Application\Traits\ContratAwareTrait;
use \Application\Entity\Db\Traits\ContratAwareTrait;
public function init()
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment