Commit acd9ef35 authored by Maxime Reyrolle's avatar Maxime Reyrolle

Merge branch '1056-reintegrer-les-extensions-chorus-et-marche-dans-pastell' into 'master'

Resolve "Réintégrer les extensions Chorus et Marché dans le coeur de Pastell"

Closes #1056

See merge request libriciel/pole-plate-formes/pastell/pastell!557
parents 7ff955d9 52b3c3d7
Pipeline #11168 canceled with stages
......@@ -258,3 +258,11 @@ if (!defined("CONNECTEUR_DROIT")) {
if (!defined("HTTP_PROXY_URL")) {
define("HTTP_PROXY_URL", "");
}
// Liste des packs (! si il y avait des extensions correspondantes il faut les enlever)
if (!defined("LIST_PACK")) {
define("LIST_PACK", [
"pack_chorus_pro" => false,
"pack_marche" => false
]);
}
<?php
use Pastell\Service\Pack\PackService;
class AideControler extends PastellControler
{
......@@ -57,6 +59,11 @@ class AideControler extends PastellControler
$this->{'template_milieu'} = "AideAPropos";
$this->{'changelog'} = $this->parsedown(__DIR__ . "/../CHANGELOG.md");
$this->{'manifest_info'} = $this->getManifestFactory()->getPastellManifest()->getInfo();
/** @var PackService $packService */
$packService = $this->getInstance(PackService::class);
$this->{'listPack'} = $packService->getListPack();
$this->renderDefault();
}
}
<?php
use Pastell\Service\Connecteur\MissingConnecteurService;
use Pastell\Service\Pack\PackService;
class SystemControler extends PastellControler
{
......@@ -28,6 +29,10 @@ class SystemControler extends PastellControler
"PHP" => $this->{'checkPHP'}['min_value'],
"OpenSSL" => '1.0.0a',
);
/** @var PackService $packService */
$packService = $this->getInstance(PackService::class);
$this->{'listPack'} = $packService->getListPack();
$this->{'manifest_info'} = $this->getManifestFactory()->getPastellManifest()->getInfo();
$cmd = OPENSSL_PATH . " version";
$openssl_version = `$cmd`;
......@@ -138,6 +143,7 @@ class SystemControler extends PastellControler
$documentType = $this->getDocumentTypeFactory()->getFluxDocumentType($id_flux);
$all_flux[$id_flux]['nom'] = $documentType->getName();
$all_flux[$id_flux]['type'] = $documentType->getType();
$all_flux[$id_flux]['list_restriction_pack'] = $documentType->getListRestrictionPack();
$definition_path = $this->getFluxDefinitionFiles()->getDefinitionPath($id_flux);
$all_flux[$id_flux]['is_valide'] = $documentTypeValidation->validate($definition_path);
}
......@@ -155,6 +161,8 @@ class SystemControler extends PastellControler
$actionExecutorFactory = $this->{'ActionExecutorFactory'};
$all_action_class = $actionExecutorFactory->getAllActionClass();
/** @var PackService $packService */
$list_pack = $this->getInstance(PackService::class)->getListPack();
$all_connecteur_type = $this->getConnecteurDefinitionFiles()->getAllType();
$all_type_entite = array_keys(Entite::getAllType());
......@@ -163,6 +171,7 @@ class SystemControler extends PastellControler
/** @var DocumentTypeValidation $documentTypeValidation */
$documentTypeValidation = $this->{'DocumentTypeValidation'};
$documentTypeValidation->setListPack($list_pack);
$documentTypeValidation->setConnecteurTypeList($all_connecteur_type);
$documentTypeValidation->setEntiteTypeList($all_type_entite);
$documentTypeValidation->setActionClassList($all_action_class);
......@@ -221,6 +230,7 @@ class SystemControler extends PastellControler
$documentType = $this->getDocumentTypeFactory()->getFluxDocumentType($id);
$name = $documentType->getName();
$this->{'description'} = $documentType->getDescription();
$this->{'list_restriction_pack'} = $documentType->getListRestrictionPack();
$this->{'all_connecteur'} = $documentType->getConnecteur();
$this->{'all_action'} = $this->getAllActionInfo($documentType);
......
......@@ -93,3 +93,5 @@ $objectInstancier->setInstance(HTMLPurifier::class, $htmlPurifier);
$objectInstancier->setInstance('connecteur_droit', CONNECTEUR_DROIT);
$objectInstancier->setInstance('http_proxy_url', HTTP_PROXY_URL);
$objectInstancier->setInstance('list_pack', LIST_PACK);
......@@ -9,6 +9,7 @@ class DocumentType
public const NOM = 'nom';
public const TYPE_FLUX = 'type';
public const DESCRIPTION = 'description';
public const RESTRICTION_PACK = 'restriction_pack';
public const FORMULAIRE = 'formulaire';
public const ACTION = 'action';
......@@ -73,7 +74,12 @@ class DocumentType
}
return $this->module_definition[self::DESCRIPTION];
}
public function getListRestrictionPack(): array
{
return $this->module_definition[self::RESTRICTION_PACK] ?? [];
}
public function getType()
{
if (empty($this->module_definition[self::TYPE_FLUX])) {
......
......@@ -2,11 +2,13 @@
class DocumentTypeValidation
{
public const MODULE_DEFINITION = 'module-definition.yml';
private $yml_loader;
private $module_definition;
private $last_error;
private $list_pack = array();
private $connecteur_type_list = array();
private $entite_type_list = array();
private $action_class_list = array();
......@@ -16,7 +18,7 @@ class DocumentTypeValidation
public function __construct(YMLLoader $yml_loader)
{
$this->yml_loader = $yml_loader;
$this->module_definition = $yml_loader->getArray(__DIR__ . "/module-definition.yml");
$this->module_definition = $yml_loader->getArray(__DIR__ . "/" . self::MODULE_DEFINITION);
}
public function getLastError()
......@@ -40,6 +42,11 @@ class DocumentTypeValidation
return $module_def;
}
public function setListPack(array $list_pack)
{
$this->list_pack = $list_pack;
}
public function setConnecteurTypeList(array $connecteur_type_list)
{
$this->connecteur_type_list = $connecteur_type_list;
......@@ -73,6 +80,7 @@ class DocumentTypeValidation
$result &= $this->validatePageCondition($typeDefinition);
$result &= $this->validateOneTitre($typeDefinition);
$result &= $this->validateChoiceAction($typeDefinition);
$result &= $this->validateRestrictionPack($typeDefinition, $this->list_pack);
$result &= $this->validateConnecteur($typeDefinition, $this->connecteur_type_list);
$result &= $this->validateOnChange($typeDefinition);
$result &= $this->validateIsEqual($typeDefinition);
......@@ -295,7 +303,20 @@ class DocumentTypeValidation
}
return $result;
}
private function validateRestrictionPack(array $typeDefinition, array $list_pack): bool
{
$restriction_pack_list = $this->getList($typeDefinition, 'restriction_pack');
$result = true;
foreach ($restriction_pack_list as $restriction_pack) {
if (!array_key_exists($restriction_pack, $list_pack)) {
$this->last_error[] = "restriction_pack:<b>$restriction_pack</b> n'est pas défini dans la liste des packs";
$result = false;
}
}
return $result;
}
private function validateConnecteur(array $typeDefinition, array $connecteur_type_list)
{
$connecteur_list = $this->getList($typeDefinition, 'connecteur');
......
......@@ -12,13 +12,18 @@ definition.yml:
description:
info: Permet de décrire le module
type: string
connecteur:
type: string
restriction_pack:
info: Liste des restrictions d'utilisation pack (pack_chorus_pro, pack_marche...)
default: aucune restriction
type: list
connecteur:
info: Liste des types de connecteur utilisés par le module
default: aucun connecteur
type: list
formulaire:
info: Définition du formulaire permettant la création et l'évolution du dossier
default: pas de formulaire
......@@ -55,20 +60,25 @@ definition.yml:
info: Liste des champs de type file utilisés dans le calcul à la limite définie par la clé threshold_size (optionnel, tous les champs `file` par défaut)
type: list
restriction_pack:
possible_key:
*:
key_name: restriction_pack
type: string
connecteur:
possible_key:
*:
key_name: connecteur
type: string
type: string
formulaire:
possible_key:
*:
key_name: onglet
type: associative_array
info: le formulaire est composé d'un ensemble d'onglets
onglet:
possible_key:
*:
......
<?php
namespace Pastell\Service\Pack;
class PackService
{
private $list_pack = [];
/**
* PackService constructor.
* @param array $list_pack
*/
public function __construct(
array $list_pack = []
) {
$this->list_pack = $list_pack;
}
/**
* @return array
*/
public function getListPack(): array
{
return $this->list_pack;
}
/**
* @param array $restriction_pack
* @return bool
*/
public function hasOneOrMorePackEnabled(array $restriction_pack = []): bool
{
if (empty($restriction_pack)) {
return true;
}
foreach ($restriction_pack as $pack) {
if (array_key_exists($pack, $this->list_pack) && ($this->list_pack[$pack] === true)) {
return true;
}
}
return false;
}
}
......@@ -25,6 +25,27 @@
</div>
<div class="box">
<h2>Liste des Packs</h2>
<table class='table table-striped'>
<?php foreach ($listPack as $pack => $enabled) : ?>
<tr>
<th class="w140"><?php hecho($pack)?></th>
<td>
<?php if ($enabled) : ?>
<p class="alert alert-success">
<b>Activé</b>
</p>
<?php else : ?>
<p class="alert alert-warning">
<b>Inactif</b>
</p>
<?php endif;?>
</td>
</tr>
<?php endforeach;?>
</table>
</div>
<div class="box">
<h2>Journal des modifications (CHANGELOG)</h2>
......
......@@ -35,9 +35,29 @@ $manifest_info = $versionController->get();
</td>
</tr>
</table>
</div>
<div class="box">
<h2>Liste des Packs</h2>
<table class='table table-striped'>
<?php foreach ($listPack as $pack => $enabled) : ?>
<tr>
<th class="w140"><?php hecho($pack)?></th>
<td>
<?php if ($enabled) : ?>
<p class="alert alert-success">
<b>Activé</b>
</p>
<?php else : ?>
<p class="alert alert-warning">
<b>Inactif</b>
</p>
<?php endif;?>
</td>
</tr>
<?php endforeach;?>
</table>
</div>
<div class="box">
<h2>Workspace</h2>
......
......@@ -8,6 +8,7 @@
<th class="w200">Nom symbolique</th>
<th class="w200">Libellé</th>
<th>Module valide</th>
<th>Restrction Pack</th>
</tr>
<?php foreach ($all_flux as $id_flux => $flux) : ?>
<tr>
......@@ -18,6 +19,11 @@
<b><a href='<?php $this->url("System/fluxDetail?id=$id_flux"); ?>'>Erreur sur le type de dossier !</a></b>
<?php endif;?>
</td>
<td>
<?php if ($flux['list_restriction_pack']) : ?>
<?php hecho(implode(", ", $flux['list_restriction_pack'])); ?>
<?php endif;?>
</td>
</tr>
<?php endforeach;?>
</table>
......
......@@ -30,10 +30,22 @@
<?php if ($description) :?>
<?php echo nl2br($description)?>
<?php else : ?>
<div class='alert'>Il n'y a pas de description pour ce type de dossier.</div>
<div class='alert'>Il n'y a pas de description pour ce type de dossier</div>
<?php endif;?>
</div>
<div class="box">
<h2>Restriction Pack pour ce type de dossier :</h2>
<?php if ($list_restriction_pack) :?>
<ul>
<?php foreach ($list_restriction_pack as $restriction_pack) :?>
<li><?php hecho($restriction_pack) ?></li>
<?php endforeach; ?>
</ul>
<?php else : ?>
<div>Il n'y a pas de restriction pour ce type de dossier</div>
<?php endif;?>
</div>
<div class="box">
<h2>Connecteurs utilisés par ce type de dossier :</h2>
......
......@@ -3,6 +3,9 @@ type: Flux de test
description: flux de test, ne pas utiliser.
restriction_pack:
pack_marche
connecteur:
SAE
......
......@@ -33,7 +33,13 @@ class DocumentTypeTest extends PHPUnit\Framework\TestCase
$this->assertEquals("flux de test, ne pas utiliser.", $documentType->getDescription());
$this->assertEquals("Flux de test", $documentType->getType());
}
public function testGetListRestrictionPack()
{
$documentType = $this->getDocumentType();
$this->assertEquals(array('pack_marche'), $documentType->getListRestrictionPack());
}
public function testGetConnecteur()
{
$documentType = $this->getDocumentType();
......@@ -94,6 +100,7 @@ class DocumentTypeTest extends PHPUnit\Framework\TestCase
$documentType = $this->getEmptyDocumentType();
$this->assertEquals("test", $documentType->getName());
$this->assertFalse($documentType->getDescription());
$this->assertEmpty($documentType->getListRestrictionPack());
$this->assertEquals(DocumentType::TYPE_FLUX_DEFAULT, $documentType->getType());
$this->assertEmpty($documentType->getConnecteur());
$this->assertEmpty($documentType->getPageCondition());
......
......@@ -10,6 +10,7 @@ class DocumentTypeValidationTest extends PHPUnit\Framework\TestCase
protected function setUp()
{
$this->documentTypeValidation = new DocumentTypeValidation(new YMLLoader(new MemoryCacheNone()));
$this->documentTypeValidation->setListPack(["pack_chorus_pro" => false, "pack_marche" => false]);
$this->documentTypeValidation->setConnecteurTypeList(array('mailsec'));
$this->documentTypeValidation->setActionClassList(array('Supprimer','StandardAction','Defaut'));
$this->documentTypeValidation->setEntiteTypeList(array());
......@@ -60,4 +61,15 @@ class DocumentTypeValidationTest extends PHPUnit\Framework\TestCase
{
$this->assertTrue($this->documentTypeValidation->validate(__DIR__ . "/fixtures/definition-with-modification-no-change-etat.yml"));
}
public function testRestrictionPack()
{
$this->assertTrue($this->documentTypeValidation->validate(__DIR__ . "/fixtures/definition-with-restriction-pack.yml"));
}
public function testRestrictionPackAbsent()
{
$this->assertFalse($this->documentTypeValidation->validate(__DIR__ . "/fixtures/definition-with-wrong_restriction-pack.yml"));
$this->assertEquals("restriction_pack:<b>pack_wrong_pack</b> n'est pas défini dans la liste des packs", $this->documentTypeValidation->getLastError()[0]);
}
}
nom: Flux de test
description: Ceci est un flux de test
restriction_pack:
pack_marche
formulaire:
Message:
test:
nom: Flux de test
description: Ceci est un flux de test
restriction_pack:
pack_wrong_pack
formulaire:
Message:
test:
<?php
namespace Pastell\Tests\Service\Pack;
use Pastell\Service\Pack\PackService;
use PastellTestCase;
class PackServiceTest extends PastellTestCase
{
public function testNoRestrictionPack()
{
$restriction_pack = [];
$packService = $this->getObjectInstancier()->getInstance(PackService::class);
$this->assertTrue($packService->hasOneOrMorePackEnabled($restriction_pack));
}
public function testHasRestrictionPackWithNoEnabledPack()
{
$restriction_pack = ['pack_chorus_pro', 'pack_marche'];
$packService = $this->getObjectInstancier()->getInstance(PackService::class);
$this->assertFalse($packService->hasOneOrMorePackEnabled($restriction_pack));
}
public function testHasRestrictionPackWithEnabledPack()
{
$restriction_pack = ['pack_chorus_pro', 'pack_marche'];
$this->getObjectInstancier()->setInstance('list_pack', ["pack_chorus_pro" => true, "pack_marche" => false]);
$packService = $this->getObjectInstancier()->getInstance(PackService::class);
$this->assertTrue($packService->hasOneOrMorePackEnabled($restriction_pack));
}
}
Markdown is supported
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