|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Kreta package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
|
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
declare(strict_types=1); |
|
14
|
|
|
|
|
15
|
|
|
namespace Kreta\IdentityAccess\Infrastructure\Symfony\HttpAction; |
|
16
|
|
|
|
|
17
|
|
|
use Kreta\IdentityAccess\Application\Query\UsersOfIdsQuery; |
|
18
|
|
|
use Kreta\SharedKernel\Application\QueryBus; |
|
19
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
20
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
21
|
|
|
|
|
22
|
|
|
class UsersByIdsAction |
|
23
|
|
|
{ |
|
24
|
|
|
private $queryBus; |
|
25
|
|
|
|
|
26
|
|
|
public function __construct(QueryBus $queryBus) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->queryBus = $queryBus; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function __invoke(Request $request) : JsonResponse |
|
32
|
|
|
{ |
|
33
|
|
|
$ids = explode(',', $request->query->get('ids')); |
|
34
|
|
|
|
|
35
|
|
|
$this->queryBus->handle( |
|
36
|
|
|
new UsersOfIdsQuery($ids), |
|
37
|
|
|
$result |
|
38
|
|
|
); |
|
39
|
|
|
|
|
40
|
|
|
return new JsonResponse($result); |
|
41
|
|
|
|
|
42
|
|
|
return new JsonResponse([ |
|
|
|
|
|
|
43
|
|
|
[ |
|
44
|
|
|
'id' => '61c0d185-fc68-46f2-9c5f-783dc6096029', |
|
45
|
|
|
'username' => 'gorkalaucirica', |
|
46
|
|
|
'email' => '[email protected]', |
|
47
|
|
|
'first_name' => 'Gorka', |
|
48
|
|
|
'last_name' => 'Laucirica', |
|
49
|
|
|
'full_name' => 'Gorka Laucirica', |
|
50
|
|
|
'image' => '/images/gorka.jpg', |
|
51
|
|
|
], [ |
|
52
|
|
|
'id' => 'a38f8ef4-400b-4229-a5ff-712ff5f72b27', |
|
53
|
|
|
'username' => 'benatespina', |
|
54
|
|
|
'email' => '[email protected]', |
|
55
|
|
|
'first_name' => 'Beñat', |
|
56
|
|
|
'last_name' => 'Espiña', |
|
57
|
|
|
'full_name' => 'Beñat Espiña', |
|
58
|
|
|
'image' => '/images/bespina.jpg', |
|
59
|
|
|
], |
|
60
|
|
|
]); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return,dieorexitstatements that have been added for debug purposes.In the above example, the last
return falsewill never be executed, because a return statement has already been met in every possible execution path.