1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* (c) Tomasz Kunicki <[email protected]> |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
*/ |
8
|
|
|
namespace AppBundle\Controller\Unit; |
9
|
|
|
|
10
|
|
|
use Domain\Unit\UseCase\ListUnit\UnitListItem; |
11
|
|
|
use Domain\Unit\UseCase\ListUnit\UnitListResponderInterface; |
12
|
|
|
use Domain\Unit\UseCase\ListUnit\UnitListResponse; |
13
|
|
|
use Domain\Unit\UseCase\ListUnit\UnitListUseCase; |
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
15
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class ListUnitController |
19
|
|
|
* |
20
|
|
|
* @package AppBundle\Controller |
21
|
|
|
* @Route(service="unit.controller.list_unit") |
22
|
|
|
*/ |
23
|
|
|
class ListUnitController extends Controller implements UnitListResponderInterface |
24
|
|
|
{ |
25
|
|
|
/** @var UnitListUseCase */ |
26
|
|
|
private $unitListUseCase; |
27
|
|
|
|
28
|
|
|
/** @var UnitListItem[] */ |
29
|
|
|
private $listItems; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* ListUnitController constructor. |
33
|
|
|
* |
34
|
|
|
* @param UnitListUseCase $unitListUseCase |
35
|
|
|
*/ |
36
|
|
|
public function __construct(UnitListUseCase $unitListUseCase) |
37
|
|
|
{ |
38
|
|
|
$this->unitListUseCase = $unitListUseCase; |
39
|
|
|
$this->unitListUseCase->addResponder($this); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
44
|
|
|
* @Route("/", name="unit_list") |
45
|
|
|
*/ |
46
|
|
|
public function listAction() |
47
|
|
|
{ |
48
|
|
|
$this->unitListUseCase->execute(); |
49
|
|
|
|
50
|
|
|
return $this->render('AppBundle:Unit:list.html.twig', array( |
51
|
|
|
'items' => $this->listItems |
52
|
|
|
)); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param UnitListResponse $response |
57
|
|
|
*/ |
58
|
|
|
public function unitListFetched(UnitListResponse $response) |
59
|
|
|
{ |
60
|
|
|
$this->listItems = $response->getList(); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|