mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 11:33:49 +00:00
FEATURE [activity][docs] generic doc for activity documents in person context
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\Service\GenericDoc\Providers;
|
||||
|
||||
use Chill\ActivityBundle\Repository\PersonActivityDocumentACLAwareRepository;
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
||||
use Chill\DocStoreBundle\GenericDoc\FetchQueryInterface;
|
||||
use Chill\DocStoreBundle\GenericDoc\GenericDocForPersonProviderInterface;
|
||||
use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
final class PersonActivityGenericDocProvider implements GenericDocForPersonProviderInterface
|
||||
{
|
||||
public const KEY = 'person_activity_document';
|
||||
|
||||
private Security $security;
|
||||
|
||||
private PersonActivityDocumentACLAwareRepository $personActivityDocumentACLAwareRepository;
|
||||
|
||||
public function __construct(Security $security, PersonActivityDocumentACLAwareRepository $personActivityDocumentACLAwareRepository
|
||||
)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->personActivityDocumentACLAwareRepository = $personActivityDocumentACLAwareRepository;
|
||||
}
|
||||
|
||||
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||
{
|
||||
return $this->personActivityDocumentACLAwareRepository->buildFetchQueryForPerson(
|
||||
$person,
|
||||
$startDate,
|
||||
$endDate,
|
||||
$content
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Person $person
|
||||
* @return bool
|
||||
*/
|
||||
public function isAllowedForPerson(Person $person): bool
|
||||
{
|
||||
return $this->security->isGranted(ActivityVoter::SEE, $person);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user