Add guards and tests for entity workflow transitions

Introduced EntityWorkflowGuardUnsignedTransition to block transitions with pending signatures. Implemented a new center resolver and added comprehensive unit tests for verifying transition rules and permissions.
This commit is contained in:
2024-09-24 10:59:33 +02:00
parent 27df3b2c9b
commit cf2fe1bba7
4 changed files with 316 additions and 3 deletions

View File

@@ -0,0 +1,40 @@
<?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\PersonBundle\Security\CenterResolver;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Security\Resolver\CenterResolverInterface;
use Chill\MainBundle\Security\Resolver\ManagerAwareCenterResolverInterface;
use Chill\MainBundle\Security\Resolver\ManagerAwareCenterResolverTrait;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
final class AccompanyingPeriodWorkEvaluationDocumentCenterResolver implements CenterResolverInterface, ManagerAwareCenterResolverInterface
{
use ManagerAwareCenterResolverTrait;
public static function getDefaultPriority(): int
{
return 0;
}
public function resolveCenter($entity, ?array $options = []): Center|array
{
/* @var $entity AccompanyingPeriodWorkEvaluationDocument */
return $this->centerResolverManager->resolveCenters($entity->getAccompanyingPeriodWorkEvaluation()
->getAccompanyingPeriodWork()->getAccompanyingPeriod(), $options);
}
public function supports($entity, ?array $options = []): bool
{
return $entity instanceof AccompanyingPeriodWorkEvaluationDocument;
}
}