Pass all button options directly to LoginButtonEvent::addButton()

master
Lars Vierbergen 7 years ago
parent bfb05b2406
commit 4776b9075d
  1. 12
      Event/LoginButtonEvent.php
  2. 8
      Resources/views/Login/buttons.html.twig

@ -27,13 +27,13 @@ class LoginButtonEvent extends Event
{
private $buttons = [];
public function addButton($text, $linkTarget, $style = 'default', $icon = null)
public function addButton($options)
{
$this->buttons[] = [
'text' => $text,
'target' => $linkTarget,
'style' => $style,
'icon' => $icon,
$this->buttons[] = $options + [
'style' => 'default',
'icon' => null,
'url' => null,
'route' => null,
];
}

@ -1,10 +1,10 @@
<div class="panel-body">
{% for button in buttons %}
<a class="btn btn-{{ button.style }} btn-block" href="{{ url(button.target) }}">
{% if icon %}
{{ icon(icon) }}
<a class="btn btn-{{ button.style }} btn-block" href="{{ button.url?button.url:url(button.route) }}">
{% if button.icon %}
{{ icon(button.icon) }}
{% endif %}
{{ button.text }}
{{ button.label }}
</a>
{% endfor %}
</div>