Skip to content

Commit 5d7c668

Browse files
committed
AuthAdapterService optimization
1 parent 762bc92 commit 5d7c668

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/Service/Factory/AuthAdapterServiceFactory.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ class AuthAdapterServiceFactory implements FactoryInterface
2525
* @return AuthAdapterService
2626
*/
2727
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
28+
{
29+
$params = $this->getParams($container);
30+
// Create the AuthAdapter and inject dependency to its constructor.
31+
return new AuthAdapterService(...$params);
32+
}
33+
34+
/**
35+
* @param ContainerInterface $container
36+
* @return array
37+
*/
38+
public function getParams(ContainerInterface $container)
2839
{
2940
// Get Doctrine entity manager from Service Manager.
3041
$entityManager = $container->get('doctrine.entitymanager.orm_default');
@@ -62,8 +73,6 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
6273
} else {
6374
$email = "";
6475
}
65-
66-
// Create the AuthAdapter and inject dependency to its constructor.
67-
return new AuthAdapterService($entityManager, $bcrypt, $headerEnabled, $header, $email, $userEntityClassName);
76+
return [$entityManager, $bcrypt, $headerEnabled, $header, $email, $userEntityClassName];
6877
}
6978
}

0 commit comments

Comments
 (0)