mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
58 lines
1.9 KiB
PHP
58 lines
1.9 KiB
PHP
<?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);
|
|
}
|
|
}
|