Commit 35ca1ef2 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Assertion: gestion du cas où le route match est null (return false)

parent 563a7b65
Loading
Loading
Loading
Loading
+24
Changes for module/Application/src/Application/Assertion/BaseAssertion.php: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Application\Assertion\Exception\FailedAssertionException;
use Application\Assertion\Interfaces\ControllerAssertionInterface;
use Application\Assertion\Interfaces\EntityAssertionInterface;
use Application\Assertion\Interfaces\PageAssertionInterface;
use Application\RouteMatch;
use Application\Service\UserContextService;
use Application\Service\UserContextServiceAwareInterface;
use Application\Service\UserContextServiceAwareTrait;
@@ -55,6 +56,10 @@ abstract class BaseAssertion extends AbstractAssertion
     */
    private function assertPage(array $page)
    {
        if ($this->getRouteMatch() === null) {
            return false;
        }

        if ($this->pageAssertion === null) {
            return true;
        }
@@ -87,6 +92,10 @@ abstract class BaseAssertion extends AbstractAssertion
            return true;
        }

        if ($this->getRouteMatch() === null) {
            return false;
        }

        $this->initControllerAssertion();

        try {
@@ -115,6 +124,10 @@ abstract class BaseAssertion extends AbstractAssertion
            return true;
        }

        if ($this->getRouteMatch() === null) {
            return false;
        }

        $this->initEntityAssertion();

        try {
@@ -174,4 +187,15 @@ abstract class BaseAssertion extends AbstractAssertion

        return $this;
    }

    /**
     * @return RouteMatch
     */
    protected function getRouteMatch()
    {
        /** @var RouteMatch $rm */
        $rm = $this->getMvcEvent()->getRouteMatch();

        return $rm;
    }
}
 No newline at end of file
−16
Changes for module/Application/src/Application/Assertion/These/TheseAssertion.php: 0 added lines, 16 removed lines.
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ use Application\Entity\Db\These;
use Application\Entity\Db\WfEtape;
use Application\Provider\Privilege\ThesePrivileges;
use Application\Provider\Privilege\ValidationPrivileges;
use Application\RouteMatch;
use Application\Service\UserContextService;
use Application\Service\Workflow\WorkflowServiceAwareInterface;
use Application\Service\Workflow\WorkflowServiceAwareTrait;
@@ -52,10 +51,6 @@ class TheseAssertion extends BaseAssertion implements WorkflowServiceAwareInterf
            return false;
        }

//        if ($this->getRouteMatch() === null) {
//            return false;
//        }

        $these = $this->getRouteMatch()->getThese();

        switch (true) {
@@ -129,15 +124,4 @@ class TheseAssertion extends BaseAssertion implements WorkflowServiceAwareInterf

        return $this;
    }

    /**
     * @return RouteMatch
     */
    private function getRouteMatch()
    {
        /** @var RouteMatch $rm */
        $rm = $this->getMvcEvent()->getRouteMatch();

        return $rm;
    }
}
 No newline at end of file