Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Commit 94ef503

Browse files
committed
feat: compatibility with Symfony 3.4
1 parent 1182409 commit 94ef503

13 files changed

Lines changed: 62 additions & 39 deletions

File tree

DependencyInjection/Configuration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Ekino\Bundle\DrupalBundle\DependencyInjection;
1313

1414
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15-
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
1615
use Symfony\Component\Config\Definition\ConfigurationInterface;
1716

1817
/**

DependencyInjection/EkinoDrupalExtension.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@
1414
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Reference;
17-
use Symfony\Component\DependencyInjection\Definition;
1817
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
1918
use Symfony\Component\Config\FileLocator;
20-
use Symfony\Component\Config\Resource\FileResource;
21-
use Symfony\Component\Finder\Finder;
2219
use Symfony\Component\Config\Definition\Processor;
2320

2421
/**

Drupal/DrupalRequestListener.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Ekino\Bundle\DrupalBundle\Delivery\DeliveryStrategyInterface;
1515

16-
use Symfony\Component\HttpFoundation\Request;
1716
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
1817
use Symfony\Component\HttpKernel\HttpKernelInterface;
1918

Entity/FosUser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,9 @@ public function setPlainPassword($password)
607607
/**
608608
* Sets the last login time
609609
*
610-
* @param \DateTime $time
610+
* @param \DateTime|null $time
611611
*/
612-
public function setLastLogin(\DateTime $time)
612+
public function setLastLogin(\DateTime $time = null)
613613
{
614614
$this->lastLogin = $time;
615615
}

Entity/HybridUser.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111

1212
namespace Ekino\Bundle\DrupalBundle\Entity;
1313

14-
use Symfony\Component\Security\Core\User\UserInterface as SecurityUserInterface;
1514
use FOS\UserBundle\Model\UserInterface as FOSUserInterface;
1615

1716
/**
18-
* This class provide convenient proxies methods between FosUser class and a DrupalUser class
19-
*
17+
* This class provide convenient proxies methods between FosUser class and a DrupalUser class.
2018
*/
2119
abstract class HybridUser extends FosUser
2220
{

Entity/User.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,12 @@ public function getUid()
1919
{
2020
return $this->uid;
2121
}
22+
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function setSalt($salt)
27+
{
28+
$this->salt = $salt;
29+
}
2230
}

Event/Listener/UserEntityHookListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Ekino\Bundle\DrupalBundle\Event\DrupalEntityEvent;
1515
use Ekino\Bundle\DrupalBundle\Event\DrupalEntitiesEvent;
1616
use FOS\UserBundle\Model\UserManagerInterface;
17-
use Symfony\Component\HttpKernel\Log\LoggerInterface;
17+
use Psr\Log\LoggerInterface;
1818

1919
/**
2020
* These methods are called by the drupal user hook
@@ -29,7 +29,7 @@ class UserEntityHookListener
2929

3030
/**
3131
* @param \FOS\UserBundle\Model\UserManagerInterface $userManager
32-
* @param \Symfony\Component\HttpKernel\Log\LoggerInterface $logger
32+
* @param \Psr\Log\LoggerInterface $logger
3333
*/
3434
public function __construct(UserManagerInterface $userManager, LoggerInterface $logger)
3535
{
@@ -111,4 +111,4 @@ public function onPreSave(DrupalEntityEvent $event)
111111
$account->usernameCanonical = $account->name;
112112
}
113113
}
114-
}
114+
}

Event/Listener/UserRegistrationHookListener.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Ekino\Bundle\DrupalBundle\Event\DrupalEvent;
1515
use Psr\Log\LoggerInterface;
16-
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\HttpFoundation\RequestStack;
1717
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
1818
use Symfony\Component\Security\Core\User\UserInterface;
1919

@@ -30,9 +30,9 @@ class UserRegistrationHookListener
3030
protected $logger;
3131

3232
/**
33-
* @var Request
33+
* @var RequestStack
3434
*/
35-
protected $request;
35+
protected $requestStack;
3636

3737
/**
3838
* @var array
@@ -41,13 +41,13 @@ class UserRegistrationHookListener
4141

4242
/**
4343
* @param LoggerInterface $logger
44-
* @param Request $request
44+
* @param RequestStack $requestStack
4545
* @param array $providerKeys
4646
*/
47-
public function __construct(LoggerInterface $logger, Request $request, array $providerKeys)
47+
public function __construct(LoggerInterface $logger, RequestStack $requestStack, array $providerKeys)
4848
{
4949
$this->logger = $logger;
50-
$this->request = $request;
50+
$this->requestStack = $requestStack;
5151
$this->providerKeys = $providerKeys;
5252
}
5353

@@ -64,12 +64,14 @@ public function onLogin(DrupalEvent $event)
6464
throw new \RuntimeException('An instance of UserInterface is expected');
6565
}
6666

67+
$request = $this->requestStack->getMasterRequest();
68+
6769
// The ContextListener from the Security component is hijacked to insert a valid token into session
6870
// so next time the user go to a valid symfony2 url with a proper security context, then the following token
6971
// will be used
7072
foreach ($this->providerKeys as $providerKey) {
7173
$token = new UsernamePasswordToken($user, null, $providerKey, $user->getRoles());
72-
$this->request->getSession()->set('_security_'.$providerKey, serialize($token));
74+
$request->getSession()->set('_security_'.$providerKey, serialize($token));
7375
}
7476
}
7577

@@ -78,8 +80,10 @@ public function onLogin(DrupalEvent $event)
7880
*/
7981
public function onLogout(DrupalEvent $event)
8082
{
83+
$request = $this->requestStack->getMasterRequest();
84+
8185
foreach ($this->providerKeys as $providerKey) {
82-
$this->request->getSession()->set('_security_'.$providerKey, null);
86+
$request->getSession()->set('_security_'.$providerKey, null);
8387
}
8488
}
8589
}

Listener/ExceptionListener.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Ekino\Bundle\DrupalBundle\Listener;
44

5-
use Symfony\Component\HttpFoundation\Response;
65
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
76
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
87

Log/LoggerWatchdog.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Ekino\Bundle\DrupalBundle\Log;
1313

14-
use Symfony\Component\HttpKernel\Log\LoggerInterface;
14+
use Psr\Log\LoggerInterface;
1515

1616
/**
1717
* LoggerWatchdog.
@@ -135,4 +135,4 @@ public function log($level, $message, array $context = array())
135135
watchdog('Symfony2', $message, $context, $level);
136136
}
137137
}
138-
}
138+
}

0 commit comments

Comments
 (0)