JouwWeb /
JwPersistentUser
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace JwPersistentUser; |
||
| 4 | |||
| 5 | use JwPersistentUser\Listener\WriteTokenToCookie; |
||
| 6 | use JwPersistentUser\Service\CookieAuthenticationService; |
||
| 7 | use Zend\EventManager\EventInterface; |
||
| 8 | use Zend\EventManager\EventManager; |
||
| 9 | use Zend\ModuleManager\Feature; |
||
| 10 | use Zend\ServiceManager\ServiceManager; |
||
| 11 | |||
| 12 | class Module implements |
||
| 13 | Feature\ConfigProviderInterface, |
||
| 14 | Feature\BootstrapListenerInterface, |
||
| 15 | Feature\AutoloaderProviderInterface |
||
| 16 | { |
||
| 17 | public function getConfig() |
||
| 18 | { |
||
| 19 | return include __DIR__ . '/config/module.config.php'; |
||
| 20 | } |
||
| 21 | |||
| 22 | public function onBootstrap(EventInterface $e) |
||
| 23 | { |
||
| 24 | /** @var EventManager $em */ |
||
| 25 | $em = $e->getApplication()->getEventManager(); |
||
| 26 | |||
| 27 | /** @var ServiceManager $sm */ |
||
| 28 | $sm = $e->getApplication()->getServiceManager(); |
||
| 29 | |||
| 30 | $request = $e->getApplication()->getRequest(); |
||
| 31 | $response = $e->getApplication()->getResponse(); |
||
| 32 | |||
| 33 | // Try to login from Cookie if applicable |
||
| 34 | $service = new CookieAuthenticationService($sm); |
||
| 35 | $service->setEventManager(new EventManager($em->getSharedManager())); |
||
| 36 | $service->loginFrom($request, $response); |
||
| 37 | |||
| 38 | (new WriteTokenToCookie($sm))->attachShared($em->getSharedManager()); |
||
|
0 ignored issues
–
show
|
|||
| 39 | } |
||
| 40 | |||
| 41 | public function getAutoloaderConfig() |
||
| 42 | { |
||
| 43 | return [ |
||
| 44 | 'Zend\Loader\StandardAutoloader' => [ |
||
| 45 | 'namespaces' => [ |
||
| 46 | __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, |
||
| 47 | ], |
||
| 48 | ], |
||
| 49 | ]; |
||
| 50 | } |
||
| 51 | } |
||
| 52 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: