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

EntityContainer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 6
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 * EntityContainer.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           10.01.16
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\Forms;
23
24
/**
25
 * Form container with entity support
26
 *
27
 * @package        iPublikuj:Forms!
28
 * @subpackage     Forms
29
 *
30
 * @author         Adam Kadlec <[email protected]>
31
 */
32 View Code Duplication
class EntityContainer extends Forms\Container
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...
33
{
34
	/**
35
	 * Implement entity handling in form
36
	 */
37
	use TEntityContainer;
38
39
	/**
40
	 * @var ORM\EntityManager
41
	 */
42
	private $entityManager;
43
44
	/**
45
	 * @param ORM\EntityManager $entityManager
46
	 */
47
	public function __construct(ORM\EntityManager $entityManager)
48
	{
49
		parent::__construct();
50
51
		$this->entityManager = $entityManager;
52
	}
53
54
	/**
55
	 * Adds naming container to the form
56
	 *
57
	 * @param string $name
58
	 *
59
	 * @return EntityContainer
60
	 */
61
	public function addContainer($name) : EntityContainer
62
	{
63
		$control = new self($this->entityManager);
64
		$control->setCurrentGroup($this->currentGroup);
65
66
		return $this[$name] = $control;
67
	}
68
}
69