diff --git a/Entity/ExternalUser.php b/Entity/ExternalUser.php
index a8388cb..58f3758 100644
--- a/Entity/ExternalUser.php
+++ b/Entity/ExternalUser.php
@@ -60,6 +60,13 @@ class ExternalUser
*/
private $provider_ref;
+ /**
+ * @ORM\Column(type="string")
+ * @Gedmo\Versioned
+ * @var string
+ */
+ private $providerFriendlyName;
+
/**
* @return int
*/
@@ -124,4 +131,23 @@ class ExternalUser
return $this;
}
+
+ /**
+ * @return string
+ */
+ public function getProviderFriendlyName()
+ {
+ return $this->providerFriendlyName?:('Ref: '.$this->getProviderRef());
+ }
+
+ /**
+ * @param string $providerFriendlyName
+ * @return ExternalUser
+ */
+ public function setProviderFriendlyName($providerFriendlyName)
+ {
+ $this->providerFriendlyName = $providerFriendlyName;
+
+ return $this;
+ }
}
diff --git a/Event/LoginButtonEvent.php b/Event/LoginButtonEvent.php
index 00b4c86..ebc0754 100644
--- a/Event/LoginButtonEvent.php
+++ b/Event/LoginButtonEvent.php
@@ -22,21 +22,50 @@ 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 = [];
- public function addButton($options)
+ /**
+ * @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)
{
- $this->buttons[] = $options + [
- 'style' => 'default',
- 'icon' => null,
- 'url' => null,
- 'route' => null,
- ];
+ 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;
diff --git a/EventListener/LoginTemplateEventListener.php b/EventListener/LoginTemplateEventListener.php
index 65f44ba..efeedc7 100644
--- a/EventListener/LoginTemplateEventListener.php
+++ b/EventListener/LoginTemplateEventListener.php
@@ -26,6 +26,7 @@ use App\Event\TemplateEvent;
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use vierbergenlars\AuthserverExternalAccountBundle\Event\LoginButtonEvent;
use vierbergenlars\AuthserverExternalAccountBundle\ExternalAccountEvents;
@@ -35,11 +36,16 @@ class LoginTemplateEventListener implements EventSubscriberInterface
* @var EventDispatcherInterface
*/
private $eventDispatcher;
+ /**
+ * @var UrlGeneratorInterface
+ */
+ private $urlGenerator;
- public function __construct(EventDispatcherInterface $eventDispatcher)
+ public function __construct(EventDispatcherInterface $eventDispatcher, UrlGeneratorInterface $urlGenerator)
{
$this->eventDispatcher = $eventDispatcher;
+ $this->urlGenerator = $urlGenerator;
}
public static function getSubscribedEvents()
@@ -51,7 +57,7 @@ class LoginTemplateEventListener implements EventSubscriberInterface
public function onLoginViewBody(TemplateEvent $event)
{
- $loginButtonEvent = new LoginButtonEvent();
+ $loginButtonEvent = new LoginButtonEvent($this->urlGenerator);
$this->eventDispatcher->dispatch(ExternalAccountEvents::LOGIN_BUTTON, $loginButtonEvent);
$buttons = $loginButtonEvent->getButtons();
diff --git a/Resources/config/services.xml b/Resources/config/services.xml
index ebed173..05b7eb7 100644
--- a/Resources/config/services.xml
+++ b/Resources/config/services.xml
@@ -25,6 +25,7 @@