@@ 31-67 (lines=37) @@ | ||
28 | * |
|
29 | * @author Adam Kadlec <[email protected]> |
|
30 | */ |
|
31 | class EntityContainer extends Forms\Container |
|
32 | { |
|
33 | /** |
|
34 | * Implement entity handling in form |
|
35 | */ |
|
36 | use TEntityContainer; |
|
37 | ||
38 | /** |
|
39 | * @var ORM\EntityManager |
|
40 | */ |
|
41 | private $entityManager; |
|
42 | ||
43 | /** |
|
44 | * @param ORM\EntityManager $entityManager |
|
45 | */ |
|
46 | public function __construct(ORM\EntityManager $entityManager) |
|
47 | { |
|
48 | parent::__construct(); |
|
49 | ||
50 | $this->entityManager = $entityManager; |
|
51 | } |
|
52 | ||
53 | /** |
|
54 | * Adds naming container to the form |
|
55 | * |
|
56 | * @param string $name |
|
57 | * |
|
58 | * @return EntityContainer |
|
59 | */ |
|
60 | public function addContainer($name) : EntityContainer |
|
61 | { |
|
62 | $control = new self($this->entityManager); |
|
63 | $control->setCurrentGroup($this->currentGroup); |
|
64 | ||
65 | return $this[$name] = $control; |
|
66 | } |
|
67 | } |
|
68 |
@@ 31-78 (lines=48) @@ | ||
28 | * |
|
29 | * @author Adam Kadlec <[email protected]> |
|
30 | */ |
|
31 | class EntityForm extends Application\UI\Form |
|
32 | { |
|
33 | /** |
|
34 | * Implement entity handling in form |
|
35 | */ |
|
36 | use TEntityContainer; |
|
37 | ||
38 | /** |
|
39 | * Implement form methods |
|
40 | */ |
|
41 | use TForm; |
|
42 | ||
43 | /** |
|
44 | * @var ORM\EntityManager |
|
45 | */ |
|
46 | private $entityManager; |
|
47 | ||
48 | /** |
|
49 | * @param ORM\EntityManager $entityManager |
|
50 | */ |
|
51 | public function injectEntityManager(ORM\EntityManager $entityManager) : void |
|
52 | { |
|
53 | $this->entityManager = $entityManager; |
|
54 | } |
|
55 | ||
56 | /** |
|
57 | * Adds naming container to the form |
|
58 | * |
|
59 | * @param string $name |
|
60 | * |
|
61 | * @return EntityContainer |
|
62 | */ |
|
63 | public function addContainer($name) : EntityContainer |
|
64 | { |
|
65 | $control = new EntityContainer($this->entityManager); |
|
66 | $control->setCurrentGroup($this->currentGroup); |
|
67 | ||
68 | return $this[$name] = $control; |
|
69 | } |
|
70 | ||
71 | /** |
|
72 | * @return ORM\EntityManager |
|
73 | */ |
|
74 | protected function getEntityManager() : ORM\EntityManager |
|
75 | { |
|
76 | return $this->entityManager; |
|
77 | } |
|
78 | } |
|
79 |