/** * This method performs a check to verify if the filtered badge (if present) * belongs to the namespace of this evaluator. * * @param ListBearersEvent $event */ public function onListBearersPreFilter(ListBearersEvent $event) { $filterBadge = $event->getBadge(); if ($filterBadge instanceof BadgeInterface) { if ($filterBadge->getNamespace() !== $this->getName()) { return; } } $this->onListBearers($event); }
public function onListBearers(ListBearersEvent $event) { $filterBadge = $event->getBadge(); if ($filterBadge instanceof BadgeInterface) { $countMethod = $this->badges[$filterBadge->getName()]['counter']; $count = $this->{$countMethod}($filterBadge->getData()); $event->setCount($filterBadge, $count); } else { foreach ($this->badges as $name => $badge) { $countMethod = $badge['counter']; $count = $this->{$countMethod}(); $badge = new Badge($this->getName(), $name); $event->setCount($badge, $count); } } }
public function onListBearers(ListBearersEvent $event) { if (!$this->security->isGranted(self::FEATURE_FLAG)) { return; } $filterBadge = $event->getBadge(); if ($filterBadge instanceof BadgeInterface) { $countMethod = $this->badges[$filterBadge->getName()]['counter']; $count = $this->{$countMethod}($filterBadge->getData()); $event->setCount($filterBadge, $count); } else { foreach ($this->badges as $name => $badge) { $countMethod = $badge['counter']; $count = $this->{$countMethod}(); $badge = new Badge($this->getName(), $name); $event->setCount($badge, $count); } } }