1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Silverback API Components Bundle Project |
5
|
|
|
* |
6
|
|
|
* (c) Daniel West <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Silverback\ApiComponentsBundle\Entity\Utility; |
15
|
|
|
|
16
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
17
|
|
|
use Doctrine\Common\Collections\Collection; |
18
|
|
|
use Doctrine\ORM\Mapping as ORM; |
19
|
|
|
use Silverback\ApiComponentsBundle\Entity\Core\ComponentGroup; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Daniel West <[email protected]> |
23
|
|
|
* |
24
|
|
|
* @internal |
25
|
|
|
*/ |
26
|
|
|
trait UiTrait |
27
|
|
|
{ |
28
|
|
|
#[Orm\Column(nullable: true)] |
29
|
|
|
public ?string $uiComponent = null; |
30
|
|
|
|
31
|
|
|
#[Orm\Column(type: 'json', nullable: true)] |
32
|
|
|
public ?array $uiClassNames = null; |
33
|
|
|
|
34
|
|
|
/** * |
35
|
|
|
* @var Collection|ComponentGroup[] |
36
|
|
|
*/ |
37
|
|
|
#[Orm\ManyToMany(targetEntity: ComponentGroup::class)] |
38
|
|
|
private Collection $componentGroups; |
39
|
|
|
|
40
|
|
|
public function __construct() |
41
|
|
|
{ |
42
|
|
|
$this->initComponentGroups(); |
43
|
|
|
} |
44
|
|
|
|
45
|
9 |
|
private function initComponentGroups(): void |
46
|
|
|
{ |
47
|
9 |
|
$this->componentGroups = new ArrayCollection(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return Collection|ComponentGroup[] |
52
|
|
|
*/ |
53
|
1 |
|
public function getComponentGroups() |
54
|
|
|
{ |
55
|
1 |
|
return $this->componentGroups; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return static |
60
|
|
|
*/ |
61
|
|
|
public function setComponentGroups(iterable $componentGroups) |
62
|
|
|
{ |
63
|
|
|
$this->componentGroups = new ArrayCollection(); |
64
|
|
|
foreach ($componentGroups as $componentGroup) { |
65
|
|
|
$this->addComponentGroup($componentGroup); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return static |
73
|
|
|
*/ |
74
|
|
|
public function addComponentGroup(ComponentGroup $componentGroup) |
75
|
|
|
{ |
76
|
|
|
if (!$this->componentGroups->contains($componentGroup)) { |
77
|
|
|
$this->componentGroups->add($componentGroup); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
return $this; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return static |
85
|
|
|
*/ |
86
|
|
|
public function removeComponentGroup(ComponentGroup $componentGroup) |
87
|
|
|
{ |
88
|
|
|
if ($this->componentGroups->contains($componentGroup)) { |
89
|
|
|
$this->componentGroups->remove($componentGroup); |
|
|
|
|
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|