mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
add delete feature for entityWorkflow (wip)
This commit is contained in:
@@ -25,6 +25,8 @@ class EntityWorkflowVoter extends Voter
|
||||
|
||||
public const SEE = 'CHILL_MAIN_WORKFLOW_SEE';
|
||||
|
||||
public const DELETE = 'CHILL_MAIN_WORKFLOW_DELETE';
|
||||
|
||||
private EntityWorkflowManager $manager;
|
||||
|
||||
private Security $security;
|
||||
@@ -40,7 +42,10 @@ class EntityWorkflowVoter extends Voter
|
||||
return $subject instanceof EntityWorkflow && in_array($attribute, self::getRoles(), true);
|
||||
}
|
||||
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||
/**
|
||||
* @param EntityWorkflow $subject
|
||||
*/
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
{
|
||||
switch ($attribute) {
|
||||
case self::CREATE:
|
||||
@@ -55,6 +60,9 @@ class EntityWorkflowVoter extends Voter
|
||||
|
||||
return $this->security->isGranted($entityAttribute, $handler->getRelatedEntity($subject));
|
||||
|
||||
case self::DELETE:
|
||||
return $subject->getStep() === 'initial';
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("attribute {$attribute} not supported");
|
||||
}
|
||||
@@ -65,6 +73,7 @@ class EntityWorkflowVoter extends Voter
|
||||
return [
|
||||
self::SEE,
|
||||
self::CREATE,
|
||||
self::DELETE,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user