|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LAG\AdminBundle\Action; |
|
4
|
|
|
|
|
5
|
|
|
use LAG\AdminBundle\Filter\Factory\FilterFormBuilder; |
|
6
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
7
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
8
|
|
|
|
|
9
|
|
|
class ListAction extends Action |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var FilterFormBuilder |
|
13
|
|
|
*/ |
|
14
|
|
|
private $filterFormBuilder; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @param Request $request |
|
18
|
|
|
* |
|
19
|
|
|
* @return Response |
|
20
|
|
|
*/ |
|
21
|
1 |
|
public function __invoke(Request $request) |
|
22
|
|
|
{ |
|
23
|
|
|
// build the filters form |
|
24
|
|
|
$filterForm = $this |
|
25
|
1 |
|
->filterFormBuilder |
|
26
|
1 |
|
->build($this->configuration) |
|
27
|
|
|
; |
|
28
|
1 |
|
$filters = []; |
|
29
|
|
|
|
|
30
|
|
|
// load the filters |
|
31
|
1 |
|
if (null !== $filterForm) { |
|
32
|
1 |
|
$filterForm->handleRequest($request); |
|
33
|
|
|
|
|
34
|
1 |
|
if ($filterForm->isSubmitted() && $filterForm->isValid()) { |
|
35
|
|
|
$filters = $filterForm->getData(); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
// load the entities |
|
40
|
|
|
$this |
|
41
|
1 |
|
->admin |
|
42
|
1 |
|
->handleRequest($request, $filters) |
|
43
|
|
|
; |
|
44
|
|
|
|
|
45
|
|
|
$form = $this |
|
46
|
1 |
|
->formFactory |
|
47
|
1 |
|
->create( |
|
48
|
1 |
|
$this->configuration->getParameter('form'), |
|
49
|
1 |
|
$this->admin->getEntities(), |
|
50
|
1 |
|
$this->configuration->getParameter('form_options') |
|
51
|
|
|
) |
|
52
|
|
|
; |
|
53
|
1 |
|
$form->handleRequest($request); |
|
54
|
|
|
|
|
55
|
1 |
|
if ($form->isSubmitted() && $form->isValid()) { |
|
|
|
|
|
|
56
|
|
|
// TODO do something with the selected entities |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
return $this |
|
|
|
|
|
|
60
|
1 |
|
->responder |
|
61
|
1 |
|
->respond($this->configuration, $this->admin, $form, $filterForm) |
|
|
|
|
|
|
62
|
|
|
; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param FilterFormBuilder $filterFormBuilder |
|
67
|
|
|
*/ |
|
68
|
1 |
|
public function setFilterFormBuilder($filterFormBuilder) |
|
69
|
|
|
{ |
|
70
|
1 |
|
$this->filterFormBuilder = $filterFormBuilder; |
|
71
|
1 |
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
This check looks for the bodies of
ifstatements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
ifbodies can be removed. If you have an empty if but statements in theelsebranch, consider inverting the condition.could be turned into
This is much more concise to read.