1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony). |
4
|
|
|
* |
5
|
|
|
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics) |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as published |
9
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
declare(strict_types=1); |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* part-db version 0.1 |
25
|
|
|
* Copyright (C) 2005 Christoph Lechner |
26
|
|
|
* http://www.cl-projects.de/. |
27
|
|
|
* |
28
|
|
|
* part-db version 0.2+ |
29
|
|
|
* Copyright (C) 2009 K. Jacobs and others (see authors.php) |
30
|
|
|
* http://code.google.com/p/part-db/ |
31
|
|
|
* |
32
|
|
|
* Part-DB Version 0.4+ |
33
|
|
|
* Copyright (C) 2016 - 2019 Jan Böhmer |
34
|
|
|
* https://github.com/jbtronics |
35
|
|
|
* |
36
|
|
|
* This program is free software; you can redistribute it and/or |
37
|
|
|
* modify it under the terms of the GNU General Public License |
38
|
|
|
* as published by the Free Software Foundation; either version 2 |
39
|
|
|
* of the License, or (at your option) any later version. |
40
|
|
|
* |
41
|
|
|
* This program is distributed in the hope that it will be useful, |
42
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
43
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
44
|
|
|
* GNU General Public License for more details. |
45
|
|
|
* |
46
|
|
|
* You should have received a copy of the GNU General Public License |
47
|
|
|
* along with this program; if not, write to the Free Software |
48
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
49
|
|
|
*/ |
50
|
|
|
|
51
|
|
|
namespace App\Entity\Parts; |
52
|
|
|
|
53
|
|
|
use App\Entity\Attachments\FootprintAttachment; |
54
|
|
|
use App\Entity\Base\AbstractPartsContainingDBElement; |
55
|
|
|
use App\Entity\Parameters\FootprintParameter; |
56
|
|
|
use Doctrine\Common\Collections\Collection; |
57
|
|
|
use Doctrine\ORM\Mapping as ORM; |
58
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Class Footprint. |
62
|
|
|
* |
63
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository") |
64
|
|
|
* @ORM\Table("`footprints`") |
65
|
|
|
*/ |
66
|
|
|
class Footprint extends AbstractPartsContainingDBElement |
67
|
|
|
{ |
68
|
|
|
/** |
69
|
|
|
* @ORM\ManyToOne(targetEntity="Footprint", inversedBy="children") |
70
|
|
|
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id") |
71
|
|
|
*/ |
72
|
|
|
protected $parent; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @ORM\OneToMany(targetEntity="Footprint", mappedBy="parent") |
76
|
|
|
* @ORM\OrderBy({"name" = "ASC"}) |
77
|
|
|
*/ |
78
|
|
|
protected $children; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @ORM\OneToMany(targetEntity="Part", mappedBy="footprint", fetch="EXTRA_LAZY") |
82
|
|
|
*/ |
83
|
|
|
protected $parts; |
84
|
|
|
/** |
85
|
|
|
* @var Collection<int, FootprintAttachment> |
86
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Attachments\FootprintAttachment", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) |
87
|
|
|
* @ORM\OrderBy({"name" = "ASC"}) |
88
|
|
|
* @Assert\Valid() |
89
|
|
|
*/ |
90
|
|
|
protected $attachments; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @var FootprintAttachment|null |
94
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Attachments\FootprintAttachment") |
95
|
|
|
* @ORM\JoinColumn(name="id_footprint_3d", referencedColumnName="id") |
96
|
|
|
*/ |
97
|
|
|
protected $footprint_3d; |
98
|
|
|
|
99
|
|
|
/** @var Collection<int, FootprintParameter> |
100
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Parameters\FootprintParameter", mappedBy="element", cascade={"persist", "remove"}, orphanRemoval=true) |
101
|
|
|
* @ORM\OrderBy({"group" = "ASC" ,"name" = "ASC"}) |
102
|
|
|
* @Assert\Valid() |
103
|
|
|
*/ |
104
|
|
|
protected $parameters; |
105
|
|
|
|
106
|
|
|
|
107
|
|
|
/**************************************** |
108
|
|
|
* Getters |
109
|
|
|
****************************************/ |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Returns the 3D Model associated with this footprint. |
113
|
|
|
*/ |
114
|
|
|
public function getFootprint3d(): ?FootprintAttachment |
115
|
|
|
{ |
116
|
|
|
return $this->footprint_3d; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/******************************************************************************** |
120
|
|
|
* |
121
|
|
|
* Setters |
122
|
|
|
* |
123
|
|
|
*********************************************************************************/ |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Sets the 3D Model associated with this footprint. |
127
|
|
|
* |
128
|
|
|
* @param FootprintAttachment|null $new_attachment The new 3D Model |
129
|
|
|
* |
130
|
|
|
* @return Footprint |
131
|
|
|
*/ |
132
|
|
|
public function setFootprint3d(?FootprintAttachment $new_attachment): self |
133
|
|
|
{ |
134
|
|
|
$this->footprint_3d = $new_attachment; |
135
|
|
|
|
136
|
|
|
return $this; |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|