|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* (c) FSi sp. z o.o. <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
declare(strict_types=1); |
|
11
|
|
|
|
|
12
|
|
|
namespace FSi\Bundle\AdminBundle\Admin\CRUD\Context; |
|
13
|
|
|
|
|
14
|
|
|
use FSi\Bundle\AdminBundle\Admin\Context\ContextAbstract; |
|
15
|
|
|
use FSi\Bundle\AdminBundle\Admin\CRUD\BatchElement; |
|
16
|
|
|
use FSi\Bundle\AdminBundle\Admin\CRUD\FormElement; |
|
17
|
|
|
use FSi\Bundle\AdminBundle\Admin\Element; |
|
18
|
|
|
use FSi\Bundle\AdminBundle\Event\AdminEvent; |
|
19
|
|
|
use FSi\Bundle\AdminBundle\Event\FormEvent; |
|
20
|
|
|
use Symfony\Component\Form\FormInterface; |
|
21
|
|
|
use Symfony\Component\Form\FormBuilderInterface; |
|
22
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
23
|
|
|
|
|
24
|
|
|
class BatchElementContext extends ContextAbstract |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @var FormElement |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $element; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var FormInterface |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $form; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var array |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $indexes; |
|
40
|
|
|
|
|
41
|
|
|
public function __construct(array $requestHandlers, FormBuilderInterface $formBuilder) |
|
42
|
|
|
{ |
|
43
|
|
|
parent::__construct($requestHandlers); |
|
44
|
|
|
$this->form = $formBuilder->getForm(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function getData(): array |
|
48
|
|
|
{ |
|
49
|
|
|
return [ |
|
50
|
|
|
'element' => $this->element, |
|
51
|
|
|
'indexes' => $this->indexes, |
|
52
|
|
|
'form' => $this->form->createView() |
|
53
|
|
|
]; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function setElement(Element $element): void |
|
57
|
|
|
{ |
|
58
|
|
|
$this->element = $element; |
|
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
protected function createEvent(Request $request): AdminEvent |
|
62
|
|
|
{ |
|
63
|
|
|
$this->indexes = $request->request->get('indexes', []); |
|
64
|
|
|
|
|
65
|
|
|
return new FormEvent($this->element, $request, $this->form); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
protected function getSupportedRoute(): string |
|
69
|
|
|
{ |
|
70
|
|
|
return 'fsi_admin_batch'; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
protected function supportsElement(Element $element): bool |
|
74
|
|
|
{ |
|
75
|
|
|
return $element instanceof BatchElement; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.