mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
create voter which blocks deletion if a workflow exists
This commit is contained in:
@@ -37,6 +37,13 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function getDeletionRoles(): array
|
||||
{
|
||||
return [
|
||||
'_',
|
||||
];
|
||||
}
|
||||
|
||||
public function getEntityData(EntityWorkflow $entityWorkflow, array $options = []): array
|
||||
{
|
||||
$doc = $this->getRelatedEntity($entityWorkflow);
|
||||
@@ -63,6 +70,18 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW
|
||||
return $this->repository->find($entityWorkflow->getRelatedEntityId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriodWorkEvaluationDocument $object
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function getRelatedObjects(object $object): array
|
||||
{
|
||||
return [
|
||||
['entityClass' => AccompanyingPeriodWorkEvaluationDocument::class, $object->getId()],
|
||||
];
|
||||
}
|
||||
|
||||
public function getRoleShow(EntityWorkflow $entityWorkflow): ?string
|
||||
{
|
||||
return AccompanyingPeriodWorkEvaluationDocumentVoter::SEE;
|
||||
@@ -84,6 +103,11 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW
|
||||
];
|
||||
}
|
||||
|
||||
public function isObjectSupported(object $object): bool
|
||||
{
|
||||
return $object instanceof AccompanyingPeriodWorkEvaluationDocument;
|
||||
}
|
||||
|
||||
public function supports(EntityWorkflow $entityWorkflow, array $options = []): bool
|
||||
{
|
||||
return $entityWorkflow->getRelatedEntityClass() === AccompanyingPeriodWorkEvaluationDocument::class;
|
||||
|
Reference in New Issue
Block a user