diff options
Diffstat (limited to 'src/model/entities/NodeDataAsset.php')
| -rw-r--r-- | src/model/entities/NodeDataAsset.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/model/entities/NodeDataAsset.php b/src/model/entities/NodeDataAsset.php new file mode 100644 index 0000000..7f7008e --- /dev/null +++ b/src/model/entities/NodeDataAsset.php | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | <?php | ||
| 2 | // src/model/entities/NodeDataAsset.php | ||
| 3 | // | ||
| 4 | // entité intermédiaire avec 3 colonnes | ||
| 5 | |||
| 6 | declare(strict_types=1); | ||
| 7 | |||
| 8 | namespace App\Entity; | ||
| 9 | |||
| 10 | use Doctrine\ORM\Mapping as ORM; | ||
| 11 | |||
| 12 | #[ORM\Entity] | ||
| 13 | #[ORM\Table(name: TABLE_PREFIX . 'nodedata_asset')] | ||
| 14 | #[ORM\UniqueConstraint(name: 'unique_role_per_node', columns: ['node_data_id', 'role'])] // un rôle UNIQUE pour chaque node_data_id, excellent! | ||
| 15 | class NodeDataAsset | ||
| 16 | { | ||
| 17 | // clé primaire double | ||
| 18 | // inconvénient: impossible d'utiliser deux fois la même paire node_data/asset, même pour des rôles différents | ||
| 19 | #[ORM\Id] | ||
| 20 | #[ORM\ManyToOne(targetEntity: NodeData::class, inversedBy: 'nda_collection')] | ||
| 21 | #[ORM\JoinColumn(name: 'node_data_id', referencedColumnName: 'id_node_data', onDelete: 'CASCADE')] | ||
| 22 | private NodeData $node_data; | ||
| 23 | |||
| 24 | #[ORM\Id] | ||
| 25 | #[ORM\ManyToOne(targetEntity: Asset::class)] | ||
| 26 | #[ORM\JoinColumn(name: 'asset_id', referencedColumnName: 'id_asset', onDelete: 'CASCADE')] | ||
| 27 | private Asset $asset; | ||
| 28 | |||
| 29 | #[ORM\Column(type: 'string', length: 50)] | ||
| 30 | private string $role; | ||
| 31 | |||
| 32 | public function __construct(NodeData $node_data, Asset $asset, string $role){ | ||
| 33 | $this->node_data = $node_data; | ||
| 34 | $this->asset = $asset; | ||
| 35 | $this->role = $role; | ||
| 36 | } | ||
| 37 | |||
| 38 | /*public function getNodeData(): NodeData | ||
| 39 | { | ||
| 40 | return $this->node_data; | ||
| 41 | }*/ | ||
| 42 | public function getAsset(): Asset | ||
| 43 | { | ||
| 44 | return $this->asset; | ||
| 45 | } | ||
| 46 | public function setAsset(Asset $asset): self | ||
| 47 | { | ||
| 48 | $this->asset = $asset; | ||
| 49 | return $this; | ||
| 50 | } | ||
| 51 | public function getRole(): string | ||
| 52 | { | ||
| 53 | return $this->role; | ||
| 54 | } | ||
| 55 | } | ||
