Implement voting logic: separation of concerns

A separate AccompanyingCourseDocumentStoredObjectVoter was\
created to handle the specific access to a Stored object\
related to an Accompanying Course Document.
This commit is contained in:
2024-06-20 15:17:56 +02:00
parent 427f232ab8
commit d26fa6bde6
3 changed files with 67 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\DocStoreBundle\Repository;
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
@@ -45,6 +46,17 @@ class AccompanyingCourseDocumentRepository implements ObjectRepository
return $qb->getQuery()->getSingleScalarResult();
}
public function findLinkedCourseDocument(int $storedObjectId): ?AccompanyingCourseDocument {
$qb = $this->repository->createQueryBuilder('d');
$query = $qb->leftJoin('d.storedObject', 'do')
->where('do.id = :storedObjectId')
->setParameter('storedObjectId', $storedObjectId)
->getQuery();
return $query->getResult();
}
public function find($id): ?AccompanyingCourseDocument
{
return $this->repository->find($id);
@@ -69,4 +81,5 @@ class AccompanyingCourseDocumentRepository implements ObjectRepository
{
return AccompanyingCourseDocument::class;
}
}