. */ namespace vierbergenlars\AuthserverExternalAccountBundle\Event; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use vierbergenlars\AuthserverExternalAccountBundle\ValueObject\Button; class LoginButtonEvent extends Event { /** * @var Button[] */ private $buttons = []; /** * @var UrlGeneratorInterface */ private $urlGenerator; /** * LoginButtonEvent constructor. * * @param UrlGeneratorInterface $urlGenerator */ public function __construct(UrlGeneratorInterface $urlGenerator) { $this->urlGenerator = $urlGenerator; } /** * @param array|Button $button */ public function addButton($button) { if(!($button instanceof Button)) { if(isset($button['route'])) { $button['url'] = $this->urlGenerator->generate($button['route']); unset($button['route']); } $button = new Button($button); } $this->buttons[] = $button; } /** * @return Button[] */ public function getButtons() { return $this->buttons; } }