mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 23:53:50 +00:00
counter created for workflows for which user is a destuser and that are not finalized
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Workflow\Counter;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\Workflow\EntityWorkflowStepRepository;
|
||||
use Chill\MainBundle\Templating\UI\NotificationCounterInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
final class WorkflowByUserCounter implements NotificationCounterInterface
|
||||
{
|
||||
private EntityWorkflowStepRepository $workflowStepRepository;
|
||||
|
||||
public function __construct(EntityWorkflowStepRepository $workflowStepRepository)
|
||||
{
|
||||
$this->workflowStepRepository = $workflowStepRepository;
|
||||
}
|
||||
|
||||
public function addNotification(UserInterface $u): int
|
||||
{
|
||||
if (!$u instanceof User) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->getCountUnreadByUser($u);
|
||||
}
|
||||
|
||||
public function getCountUnreadByUser(User $user): int
|
||||
{
|
||||
return $this->workflowStepRepository->countUnreadByUser($user);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user