mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?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\DocStoreBundle\Service;
|
|
|
|
use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
|
use Symfony\Component\Security\Core\Security;
|
|
|
|
class WorkflowDocumentService
|
|
{
|
|
public function __construct(private readonly Security $security, private readonly EntityWorkflowManager $entityWorkflowManager) {}
|
|
|
|
public function notBlockedByWorkflow(object $entity): bool
|
|
{
|
|
$workflows = $this->entityWorkflowManager->findByRelatedEntity($entity);
|
|
$currentUser = $this->security->getUser();
|
|
|
|
foreach ($workflows as $workflow) {
|
|
if ($workflow->isFinal()) {
|
|
return false;
|
|
}
|
|
|
|
if ($workflow->getCurrentStep()->getAllDestUser()->contains($currentUser)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|