Completed
Push — master ( e43ea6...048027 )
by Adam
03:04
created

EntityForm::getEntityManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * EntityForm.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        http://www.ipublikuj.eu
7
 * @author         Adam Kadlec http://www.ipublikuj.eu
8
 * @package        iPublikuj:Forms!
9
 * @subpackage     Forms
10
 * @since          1.0.0
11
 *
12
 * @date           26.05.13
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\Forms\Forms;
18
19
use Doctrine\ORM;
20
21
use Nette;
22
use Nette\Application;
23
use Nette\ComponentModel;
24
25
/**
26
 * Form with entity support
27
 *
28
 * @package        iPublikuj:Forms!
29
 * @subpackage     Forms
30
 *
31
 * @author         Adam Kadlec <[email protected]>
32
 */
33 View Code Duplication
class EntityForm extends Application\UI\Form
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
{
35
	/**
36
	 * Implement entity handling in form
37
	 */
38
	use TEntityContainer;
39
40
	/**
41
	 * Implement form methods
42
	 */
43
	use TForm;
44
45
	/**
46
	 * @var ORM\EntityManager
47
	 */
48
	private $entityManager;
49
50
	/**
51
	 * @param ORM\EntityManager $entityManager
52
	 */
53
	public function injectEntityManager(ORM\EntityManager $entityManager)
54
	{
55
		$this->entityManager = $entityManager;
56
	}
57
58
	/**
59
	 * Adds naming container to the form
60
	 *
61
	 * @param string $name
62
	 *
63
	 * @return EntityContainer
64
	 */
65
	public function addContainer($name) : EntityContainer
66
	{
67
		$control = new EntityContainer($this->entityManager);
68
		$control->setCurrentGroup($this->currentGroup);
69
70
		return $this[$name] = $control;
71
	}
72
73
	/**
74
	 * @return ORM\EntityManager
75
	 */
76
	protected function getEntityManager() : ORM\EntityManager
77
	{
78
		return $this->entityManager;
79
	}
80
}
81