mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
FEATURE [menu][counters] show counter icon for person resources and residential address if there are any
This commit is contained in:
parent
6254303392
commit
27f13e0dd1
@ -12,11 +12,13 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Menu;
|
||||
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Chill\PersonBundle\Repository\ResidentialAddressRepository;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Add menu entrie to person menu.
|
||||
@ -35,16 +37,20 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
|
||||
protected TranslatorInterface $translator;
|
||||
|
||||
private ResidentialAddressRepository $residentialAddressRepo;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(
|
||||
ParameterBagInterface $parameterBag,
|
||||
Security $security,
|
||||
TranslatorInterface $translator
|
||||
TranslatorInterface $translator,
|
||||
ResidentialAddressRepository $residentialAddressRepo
|
||||
) {
|
||||
$this->showAccompanyingPeriod = $parameterBag->get('chill_person.accompanying_period');
|
||||
$this->security = $security;
|
||||
$this->translator = $translator;
|
||||
$this->residentialAddressRepo = $residentialAddressRepo;
|
||||
}
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
@ -67,6 +73,8 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 60,
|
||||
'counter' => count($this->residentialAddressRepo->findBy(['person' => $parameters['person']])) > 0 ?
|
||||
count($this->residentialAddressRepo->findBy(['person' => $parameters['person']])) : null,
|
||||
]);
|
||||
|
||||
$menu->addChild($this->translator->trans('person_resources_menu'), [
|
||||
@ -77,6 +85,7 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 70,
|
||||
'counter' => count($parameters['person']->getResources()) > 0 ? count($parameters['person']->getResources()) : null,
|
||||
]);
|
||||
|
||||
$menu->addChild($this->translator->trans('household.person history'), [
|
||||
|
@ -17,8 +17,12 @@
|
||||
|
||||
<div class="list-group vertical-menu {{ 'menu-' ~ menus.name }}">
|
||||
{% for menu in menus %}
|
||||
|
||||
<a class="list-group-item list-group-item-action"
|
||||
href="{{ menu.uri }}">
|
||||
{% if menu.extras.counter is defined and menu.extras.counter is not null %}
|
||||
<span class="badge rounded-pill bg-danger notification-counter">{{ menu.extras.counter }}</span>
|
||||
{% endif %}
|
||||
{{ menu.label|upper }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user