From c72813557bcb2fe83bab2e41bead5f8568cf9394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 12 Jul 2017 14:04:29 +0200 Subject: [PATCH] fix error in list rendering page --- Security/Authorization/PersonVoter.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Security/Authorization/PersonVoter.php b/Security/Authorization/PersonVoter.php index 722e962dd..210c7a690 100644 --- a/Security/Authorization/PersonVoter.php +++ b/Security/Authorization/PersonVoter.php @@ -64,14 +64,16 @@ class PersonVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte return false; } - if ($attribute === self::STATS and !$object instanceof \Chill\MainBundle\Entity\Center) { - throw new \LogicException("the expected type is \Chill\MainBundle\Entity\Center for " - . "role ".self::STATS." ".get_class($object)." given."); - } - - if ($attribute !== self::STATS and !$object instanceof \Chill\PersonBundle\Entity\Person) { - throw new \LogicException("the expected type is \Chill\PersonBundle\Entity\Person for " - . "role ".$attribute." ".get_class($object)." given."); + if ($object instanceof \Chill\MainBundle\Entity\Center) { + if (! \in_array($attribute, [ self::STATS, self::LISTS ])) { + throw new \LogicException("the expected type is \Chill\MainBundle\Entity\Center for " + . "role, '".$attribute." ".get_class($object)."' given."); + } + } elseif ($object instanceof \Chill\PersonBundle\Entity\Person) { + if (\in_array($attribute, [ self::STATS, self::LISTS ])){ + throw new \LogicException("the expected type is \Chill\PersonBundle\Entity\Person for " + . "role, '".$attribute." ".get_class($object)."' given."); + } } return $this->helper->userHasAccess($user, $object, $attribute);