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

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

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

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