1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* part-db version 0.1 |
5
|
|
|
* Copyright (C) 2005 Christoph Lechner |
6
|
|
|
* http://www.cl-projects.de/ |
7
|
|
|
* |
8
|
|
|
* part-db version 0.2+ |
9
|
|
|
* Copyright (C) 2009 K. Jacobs and others (see authors.php) |
10
|
|
|
* http://code.google.com/p/part-db/ |
11
|
|
|
* |
12
|
|
|
* Part-DB Version 0.4+ |
13
|
|
|
* Copyright (C) 2016 - 2019 Jan Böhmer |
14
|
|
|
* https://github.com/jbtronics |
15
|
|
|
* |
16
|
|
|
* This program is free software; you can redistribute it and/or |
17
|
|
|
* modify it under the terms of the GNU General Public License |
18
|
|
|
* as published by the Free Software Foundation; either version 2 |
19
|
|
|
* of the License, or (at your option) any later version. |
20
|
|
|
* |
21
|
|
|
* This program is distributed in the hope that it will be useful, |
22
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
23
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24
|
|
|
* GNU General Public License for more details. |
25
|
|
|
* |
26
|
|
|
* You should have received a copy of the GNU General Public License |
27
|
|
|
* along with this program; if not, write to the Free Software |
28
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
29
|
|
|
* |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
namespace App\Entity\Parts\PartTraits; |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
use App\Entity\Parts\Part; |
36
|
|
|
use App\Security\Annotations\ColumnSecurity; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Advanced properties of a part, not related to a more specific group. |
40
|
|
|
* @package App\Entity\Parts\PartTraits |
41
|
|
|
*/ |
42
|
|
|
trait AdvancedPropertyTrait |
43
|
|
|
{ |
44
|
|
|
/** |
45
|
|
|
* @var bool Determines if this part entry needs review (for example, because it is work in progress) |
46
|
|
|
* @ORM\Column(type="boolean") |
47
|
|
|
* @ColumnSecurity(type="boolean") |
48
|
|
|
*/ |
49
|
|
|
protected $needs_review = false; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var string A comma seperated list of tags, assocciated with the part. |
53
|
|
|
* @ORM\Column(type="text") |
54
|
|
|
* @ColumnSecurity(type="string", prefix="tags", placeholder="") |
55
|
|
|
*/ |
56
|
|
|
protected $tags = ''; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var float|null How much a single part unit weighs in gramms. |
60
|
|
|
* @ORM\Column(type="float", nullable=true) |
61
|
|
|
* @ColumnSecurity(type="float", placeholder=null) |
62
|
|
|
* @Assert\PositiveOrZero() |
63
|
|
|
*/ |
64
|
|
|
protected $mass; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Checks if this part is marked, for that it needs further review. |
68
|
|
|
* @return bool |
69
|
|
|
*/ |
70
|
|
|
public function isNeedsReview(): bool |
71
|
|
|
{ |
72
|
|
|
return $this->needs_review; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Sets the "needs review" status of this part. |
77
|
|
|
* @param bool $needs_review |
78
|
|
|
* @return Part|self |
79
|
|
|
*/ |
80
|
|
|
public function setNeedsReview(bool $needs_review): self |
81
|
|
|
{ |
82
|
|
|
$this->needs_review = $needs_review; |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Gets a comma separated list, of tags, that are assigned to this part |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
|
|
public function getTags(): string |
92
|
|
|
{ |
93
|
|
|
return $this->tags; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Sets a comma separated list of tags, that are assigned to this part. |
98
|
|
|
* @param string $tags |
99
|
|
|
* @return self |
100
|
|
|
*/ |
101
|
|
|
public function setTags(string $tags): self |
102
|
|
|
{ |
103
|
|
|
$this->tags = $tags; |
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Returns the mass of a single part unit. |
109
|
|
|
* Returns null, if the mass is unknown/not set yet |
110
|
|
|
* @return float|null |
111
|
|
|
*/ |
112
|
|
|
public function getMass(): ?float |
113
|
|
|
{ |
114
|
|
|
return $this->mass; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Sets the mass of a single part unit. |
119
|
|
|
* Sett to null, if the mass is unknown. |
120
|
|
|
* @param float|null $mass |
121
|
|
|
* @return self |
122
|
|
|
*/ |
123
|
|
|
public function setMass(?float $mass): self |
124
|
|
|
{ |
125
|
|
|
$this->mass = $mass; |
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
|
130
|
|
|
} |