mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?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\DependencyInjection\CompilerPass;
|
|
|
|
use Chill\MainBundle\Templating\UI\CountNotificationUser;
|
|
use LogicException;
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\DependencyInjection\Reference;
|
|
|
|
class NotificationCounterCompilerPass implements CompilerPassInterface
|
|
{
|
|
public function process(ContainerBuilder $container)
|
|
{
|
|
if (!$container->hasDefinition(CountNotificationUser::class)) {
|
|
throw new LogicException('The service ' . CountNotificationUser::class . ' '
|
|
. 'should be defined');
|
|
}
|
|
|
|
$notificationCounterDefinition = $container->getDefinition(CountNotificationUser::class);
|
|
|
|
foreach ($container->findTaggedServiceIds('chill.count_notification.user') as $id => $tags) {
|
|
$notificationCounterDefinition
|
|
->addMethodCall('addNotificationCounter', [new Reference($id)]);
|
|
}
|
|
}
|
|
}
|