diff --git a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php
index d7bd1f274..d0613f9a3 100644
--- a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php
+++ b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php
@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\DocStoreBundle\Entity;
+use Chill\MainBundle\Entity\HasCentersInterface;
use Chill\MainBundle\Entity\HasScopesInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\ORM\Mapping as ORM;
@@ -19,7 +20,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Entity
* @ORM\Table("chill_doc.accompanyingcourse_document")
*/
-class AccompanyingCourseDocument extends Document implements HasScopesInterface
+class AccompanyingCourseDocument extends Document implements HasScopesInterface, HasCentersInterface
{
/**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
@@ -27,6 +28,11 @@ class AccompanyingCourseDocument extends Document implements HasScopesInterface
*/
private ?AccompanyingPeriod $course = null;
+ public function getCenters(): ?iterable
+ {
+ return $this->course->getCenters();
+ }
+
public function getCourse(): ?AccompanyingPeriod
{
return $this->course;
diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig
index dffff01aa..8dea4bbe7 100644
--- a/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig
+++ b/src/Bundle/ChillDocStoreBundle/Resources/views/List/list_item.html.twig
@@ -51,16 +51,9 @@
{% if document.course is defined %}
- {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE', document) %}
- -
-
-
- {% endif %}
- {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %}
- -
-
-
- {% endif %}
+ -
+ {{ chill_entity_workflow_list('Chill\\DocStoreBundle\\Entity\\AccompanyingCourseDocument', document.id) }}
+
{% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) %}
-
{{ document.object|chill_document_button_group(document.title, is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document)) }}
@@ -69,20 +62,17 @@
{% endif %}
- -
- {{ chill_entity_workflow_list('Chill\\DocStoreBundle\\Entity\\AccompanyingCourseDocument', document.id) }}
-
- {% else %}
- {% if is_granted('CHILL_PERSON_DOCUMENT_DELETE', document) %}
- -
-
-
- {% endif %}
- {% if is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document) %}
+ {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %}
-
-
+
{% endif %}
+ {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE', document) %}
+ -
+
+
+ {% endif %}
+ {% else %}
{% if is_granted('CHILL_PERSON_DOCUMENT_SEE_DETAILS', document) %}
-
{{ document.object|chill_document_button_group(document.title, is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document)) }}
@@ -91,6 +81,16 @@
{% endif %}
+ {% if is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document) %}
+ -
+
+
+ {% endif %}
+ {% if is_granted('CHILL_PERSON_DOCUMENT_DELETE', document) %}
+ -
+
+
+ {% endif %}
{% endif %}
diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php
index 02dfb5b64..0ef1d4d49 100644
--- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php
+++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php
@@ -78,12 +78,12 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov
return [];
}
- protected function supports($attribute, $subject)
+ protected function supports($attribute, $subject): bool
{
return $this->voterHelper->supports($attribute, $subject);
}
- protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
+ protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
if (!$token->getUser() instanceof User) {
return false;
diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
index 33e9a3db6..65e1cf688 100644
--- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
+++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
@@ -16,7 +16,7 @@ use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Repository\UserACLAwareRepositoryInterface;
use Chill\MainBundle\Security\ParentRoleHelper;
-use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
+use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Core\Role\Role;
@@ -34,7 +34,7 @@ use function get_class;
*/
class AuthorizationHelper implements AuthorizationHelperInterface
{
- private CenterResolverDispatcherInterface $centerResolverDispatcher;
+ private CenterResolverManagerInterface $centerResolverManager;
private LoggerInterface $logger;
@@ -45,13 +45,13 @@ class AuthorizationHelper implements AuthorizationHelperInterface
private UserACLAwareRepositoryInterface $userACLAwareRepository;
public function __construct(
- CenterResolverDispatcherInterface $centerResolverDispatcher,
+ CenterResolverManagerInterface $centerResolverManager,
LoggerInterface $logger,
ScopeResolverDispatcher $scopeResolverDispatcher,
UserACLAwareRepositoryInterface $userACLAwareRepository,
ParentRoleHelper $parentRoleHelper
) {
- $this->centerResolverDispatcher = $centerResolverDispatcher;
+ $this->centerResolverManager = $centerResolverManager;
$this->logger = $logger;
$this->scopeResolverDispatcher = $scopeResolverDispatcher;
$this->userACLAwareRepository = $userACLAwareRepository;
@@ -252,27 +252,15 @@ class AuthorizationHelper implements AuthorizationHelperInterface
*/
public function userHasAccess(User $user, $entity, $attribute)
{
- $center = $this->centerResolverDispatcher->resolveCenter($entity);
+ $centers = $this->centerResolverManager->resolveCenters($entity);
- if (is_iterable($center)) {
- foreach ($center as $c) {
- if ($this->userHasAccessForCenter($user, $c, $entity, $attribute)) {
- return true;
- }
+ foreach ($centers as $c) {
+ if ($this->userHasAccessForCenter($user, $c, $entity, $attribute)) {
+ return true;
}
-
- return false;
}
- if ($center instanceof Center) {
- return $this->userHasAccessForCenter($user, $center, $entity, $attribute);
- }
-
- if (null === $center) {
- return false;
- }
-
- throw new UnexpectedValueException('could not resolver a center');
+ return false;
}
/**