Skip to content

Commit e086f85

Browse files
committed
optimization
1 parent 3af265c commit e086f85

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

src/Controller/Factory/AuthControllerFactory.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,40 @@
1414
*/
1515
class AuthControllerFactory implements FactoryInterface
1616
{
17+
/**
18+
* @param ContainerInterface $container
19+
* @param string $requestedName
20+
* @param array|null $options
21+
* @return object|AuthController
22+
*/
1723
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
1824
{
25+
$params = $this->getParams($container);
26+
27+
return $this->createService($params);
28+
}
29+
30+
/**
31+
* @param ContainerInterface $container
32+
* @return array
33+
* @throws \Psr\Container\ContainerExceptionInterface
34+
* @throws \Psr\Container\NotFoundExceptionInterface
35+
*/
36+
public function getParams(ContainerInterface $container)
37+
{
1938
$entityManager = $container->get('doctrine.entitymanager.orm_default');
2039
$authManager = $container->get(AuthManager::class);
2140
$authService = $container->get(AuthenticationService::class);
2241
$userManager = $container->get(UserManager::class);
23-
24-
return new AuthController($entityManager, $authManager, $authService, $userManager);
42+
return [$entityManager, $authManager, $authService, $userManager];
43+
}
44+
45+
/**
46+
* @param $params
47+
* @return AuthController
48+
*/
49+
public function createService($params)
50+
{
51+
return new AuthController(...$params);
2552
}
2653
}

0 commit comments

Comments
 (0)