Implement context-specific voters for all current entities that can be linked to a document

For reusability an AbstractStoredObjectVoter was created and a StoredObjectVoterInterface.
A WorkflowDocumentService checks whether the StoredObject is involved in a workflow.
This commit is contained in:
2024-06-26 13:45:15 +02:00
parent 4607c36b57
commit c06e76a0ee
18 changed files with 456 additions and 88 deletions

View File

@@ -99,6 +99,22 @@ class EntityWorkflowRepository implements ObjectRepository
return $this->repository->findAll();
}
public function findByRelatedEntity($entityClass, $relatedEntityId): ?EntityWorkflow
{
$qb = $this->repository->createQueryBuilder('w');
$query = $qb->where(
$qb->expr()->andX(
$qb->expr()->eq('w.relatedEntityClass', ':entity_class'),
$qb->expr()->eq('w.relatedEntityId', ':entity_id'),
)
)->setParameter('entity_class', $entityClass)
->setParameter('entity_id', $relatedEntityId);
return $query->getQuery()->getResult();
}
/**
* @param mixed|null $limit
* @param mixed|null $offset