EntityContainer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * EntityContainer.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        https://www.ipublikuj.eu
7
 * @author         Adam Kadlec <[email protected]>
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\Forms;
22
23
/**
24
 * Form container with entity support
25
 *
26
 * @package        iPublikuj:Forms!
27
 * @subpackage     Forms
28
 *
29
 * @author         Adam Kadlec <[email protected]>
30
 */
31 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...
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