Commit 71ef12a4 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Assertions OK

ménage
parent ec145954
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -8,9 +8,9 @@

$sa = $container->get(\Framework\Authorize\Authorize::class);

//$a = $sa->isAllowedController(\Application\Controller\IndexController::class, 'index');
$a = $container->get(\Framework\Navigation\Navigation::class)->home->getPage('intervenant')->getPage('validation-referentiel-prevu');

$a = $sa->isAllowedController(\Application\Controller\PeriodeController::class, 'index');

$a = $a->isVisible();
dump($a);
+0 −5
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
namespace Administration;

use Application\Provider\Privileges;
use Framework\Authorize\AssertionFactory;
use Framework\Authorize\Authorize;

return [
@@ -41,8 +40,4 @@ return [
    'controllers' => [
        Controller\GestionController::class => Controller\GestionControllerFactory::class,
    ],

    'services' => [
        Assertion\GestionAssertion::class => AssertionFactory::class,
    ],
];
 No newline at end of file
+1 −5
Original line number Diff line number Diff line
@@ -16,12 +16,8 @@ class GestionAssertion extends AbstractAssertion
    use ContextServiceAwareTrait;


    protected function assertController($controller, $action = null, $privilege = null): bool
    protected function assertController(string $controller, ?string $action): bool
    {
        if ($privilege && !$this->authorize->isAllowedPrivilege($privilege)) {
            return false;
        }

        if ($this->getServiceContext()->getIntervenant()) {
            return false;
        }
+0 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@ use Agrement\Service\TypeAgrementService;
use Agrement\Service\TypeAgrementServiceFactory;
use Agrement\View\Helper\AgrementVewHelperFactory;
use Application\Provider\Privileges;
use Framework\Authorize\AssertionFactory;
use Framework\Authorize\Authorize;


@@ -240,8 +239,6 @@ return [
        AgrementService::class     => AgrementServiceFactory::class,
        TblAgrementService::class  => TblAgrementServiceFactory::class,
        TypeAgrementService::class => TypeAgrementServiceFactory::class,
        AgrementAssertion::class   => AssertionFactory::class,

    ],
    'view_helpers' => [
        'agrement' => AgrementVewHelperFactory::class,
+4 −12
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use Application\Provider\Privileges;
use Application\Service\Traits\ContextServiceAwareTrait;
use Contrat\Service\TblContratServiceAwareTrait;
use Framework\Authorize\AbstractAssertion;
use Framework\Navigation\Page;
use Intervenant\Entity\Db\Intervenant;
use Laminas\Permissions\Acl\Resource\ResourceInterface;
use Lieu\Entity\Db\Structure;
@@ -27,13 +28,6 @@ class AgrementAssertion extends AbstractAssertion
    use WorkflowServiceAwareTrait;
    use ContextServiceAwareTrait;

    /* ---- Routage général ---- */
    public function __invoke(array $page) // gestion des visibilités de menus
    {
        return $this->assertPage($page);
    }



    protected function assertEntity(?ResourceInterface $entity = null, $privilege = null): bool
    {
@@ -79,16 +73,13 @@ class AgrementAssertion extends AbstractAssertion



    protected function assertController($controller, $action = null, $privilege = null): bool
    protected function assertController(string $controller, ?string $action): bool
    {
        $intervenant = $this->getMvcEvent()->getParam('intervenant');
        /* @var $intervenant Intervenant */
        $typeAgrement = $this->getMvcEvent()->getParam('typeAgrement');
        /* @var $typeAgrement TypeAgrement */

        // pareil si le rôle ne possède pas le privilège adéquat
        if ($privilege && !$this->authorize->isAllowedPrivilege($privilege)) return false;

        switch ($action) {
            case 'lister':
            case 'voir':
@@ -132,8 +123,9 @@ class AgrementAssertion extends AbstractAssertion



    protected function assertPage(array $page): bool
    protected function assertPage(Page $page): bool
    {
        $page = $page->getData();
        $intervenant = $this->getMvcEvent()->getParam('intervenant');

        if ($this->getServiceContext()->getIntervenant() && str_starts_with($page['route'], 'gestion/')) {
Loading