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\ComponentCollection; |
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
|
|
|
* @ORM\ManyToMany(targetEntity=ComponentCollection::class) |
36
|
|
|
* |
37
|
|
|
* @var Collection|ComponentCollection[] |
38
|
|
|
*/ |
39
|
|
|
private Collection $componentCollections; |
40
|
|
|
|
41
|
11 |
|
public function __construct() |
42
|
|
|
{ |
43
|
11 |
|
$this->initComponentCollections(); |
44
|
11 |
|
} |
45
|
|
|
|
46
|
|
|
private function initComponentCollections(): void |
47
|
|
|
{ |
48
|
|
|
$this->componentCollections = new ArrayCollection(); |
49
|
1 |
|
} |
50
|
|
|
|
51
|
1 |
|
/** |
52
|
|
|
* @return Collection|ComponentCollection[] |
53
|
|
|
*/ |
54
|
|
|
public function getComponentCollections() |
55
|
|
|
{ |
56
|
|
|
return $this->componentCollections; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return static |
61
|
|
|
*/ |
62
|
|
|
public function setComponentCollections(iterable $componentCollections) |
63
|
|
|
{ |
64
|
|
|
$this->componentCollections = new ArrayCollection(); |
65
|
|
|
foreach ($componentCollections as $componentCollection) { |
66
|
|
|
$this->addComponentCollection($componentCollection); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return static |
74
|
|
|
*/ |
75
|
|
|
public function addComponentCollection(ComponentCollection $componentCollection) |
76
|
|
|
{ |
77
|
|
|
if (!$this->componentCollections->contains($componentCollection)) { |
78
|
|
|
$this->componentCollections->add($componentCollection); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return static |
86
|
|
|
*/ |
87
|
|
|
public function removeComponentCollection(ComponentCollection $componentCollection) |
88
|
|
|
{ |
89
|
|
|
if ($this->componentCollections->contains($componentCollection)) { |
90
|
|
|
$this->componentCollections->remove($componentCollection); |
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
return $this; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|