|
24 | 24 |
|
25 | 25 | use App\Entity\Attachments\Attachment; |
26 | 26 | use App\Entity\Parameters\AbstractParameter; |
27 | | -use Doctrine\DBAL\Types\Types; |
| 27 | +use App\Entity\Contracts\CompanyInterface; |
28 | 28 | use Doctrine\ORM\Mapping as ORM; |
29 | 29 | use Symfony\Component\Serializer\Annotation\Groups; |
30 | | -use function is_string; |
31 | | -use Symfony\Component\Validator\Constraints as Assert; |
32 | 30 |
|
33 | 31 | /** |
34 | 32 | * This abstract class is used for companies like suppliers or manufacturers. |
|
38 | 36 | * @extends AbstractPartsContainingDBElement<AT, PT> |
39 | 37 | */ |
40 | 38 | #[ORM\MappedSuperclass] |
41 | | -abstract class AbstractCompany extends AbstractPartsContainingDBElement |
| 39 | +abstract class AbstractCompany extends AbstractPartsContainingDBElement implements CompanyInterface |
42 | 40 | { |
| 41 | + use CompanyTrait; |
| 42 | + |
43 | 43 | #[Groups(['company:read'])] |
44 | 44 | protected ?\DateTimeImmutable $addedDate = null; |
45 | 45 | #[Groups(['company:read'])] |
46 | 46 | protected ?\DateTimeImmutable $lastModified = null; |
47 | 47 |
|
48 | | - /** |
49 | | - * @var string The address of the company |
50 | | - */ |
51 | | - #[Groups(['full', 'company:read', 'company:write', 'import', 'extended'])] |
52 | | - #[ORM\Column(type: Types::STRING)] |
53 | | - #[Assert\Length(max: 255)] |
54 | | - protected string $address = ''; |
55 | | - |
56 | | - /** |
57 | | - * @var string The phone number of the company |
58 | | - */ |
59 | | - #[Groups(['full', 'company:read', 'company:write', 'import', 'extended'])] |
60 | | - #[ORM\Column(type: Types::STRING)] |
61 | | - #[Assert\Length(max: 255)] |
62 | | - protected string $phone_number = ''; |
63 | | - |
64 | | - /** |
65 | | - * @var string The fax number of the company |
66 | | - */ |
67 | | - #[Groups(['full', 'company:read', 'company:write', 'import', 'extended'])] |
68 | | - #[ORM\Column(type: Types::STRING)] |
69 | | - #[Assert\Length(max: 255)] |
70 | | - protected string $fax_number = ''; |
71 | | - |
72 | | - /** |
73 | | - * @var string The email address of the company |
74 | | - */ |
75 | | - #[Assert\Email] |
76 | | - #[Groups(['full', 'company:read', 'company:write', 'import', 'extended'])] |
77 | | - #[ORM\Column(type: Types::STRING)] |
78 | | - #[Assert\Length(max: 255)] |
79 | | - protected string $email_address = ''; |
80 | | - |
81 | | - /** |
82 | | - * @var string The website of the company |
83 | | - */ |
84 | | - #[Assert\Url(requireTld: false)] |
85 | | - #[Groups(['full', 'company:read', 'company:write', 'import', 'extended'])] |
86 | | - #[ORM\Column(type: Types::STRING, length: 2048)] |
87 | | - #[Assert\Length(max: 2048)] |
88 | | - protected string $website = ''; |
89 | | - |
90 | 48 | #[Groups(['company:read', 'company:write', 'import', 'full', 'extended'])] |
91 | 49 | protected string $comment = ''; |
92 | | - |
93 | | - /** |
94 | | - * @var string The link to the website of an article. Use %PARTNUMBER% as placeholder for the part number. |
95 | | - */ |
96 | | - #[ORM\Column(type: Types::STRING, length: 2048)] |
97 | | - #[Assert\Length(max: 2048)] |
98 | | - #[Groups(['full', 'company:read', 'company:write', 'import', 'extended'])] |
99 | | - protected string $auto_product_url = ''; |
100 | | - |
101 | | - /******************************************************************************** |
102 | | - * |
103 | | - * Getters |
104 | | - * |
105 | | - *********************************************************************************/ |
106 | | - |
107 | | - /** |
108 | | - * Get the address. |
109 | | - * |
110 | | - * @return string the address of the company (with "\n" as line break) |
111 | | - */ |
112 | | - public function getAddress(): string |
113 | | - { |
114 | | - return $this->address; |
115 | | - } |
116 | | - |
117 | | - /** |
118 | | - * Get the phone number. |
119 | | - * |
120 | | - * @return string the phone number of the company |
121 | | - */ |
122 | | - public function getPhoneNumber(): string |
123 | | - { |
124 | | - return $this->phone_number; |
125 | | - } |
126 | | - |
127 | | - /** |
128 | | - * Get the fax number. |
129 | | - * |
130 | | - * @return string the fax number of the company |
131 | | - */ |
132 | | - public function getFaxNumber(): string |
133 | | - { |
134 | | - return $this->fax_number; |
135 | | - } |
136 | | - |
137 | | - /** |
138 | | - * Get the e-mail address. |
139 | | - * |
140 | | - * @return string the e-mail address of the company |
141 | | - */ |
142 | | - public function getEmailAddress(): string |
143 | | - { |
144 | | - return $this->email_address; |
145 | | - } |
146 | | - |
147 | | - /** |
148 | | - * Get the website. |
149 | | - * |
150 | | - * @return string the website of the company |
151 | | - */ |
152 | | - public function getWebsite(): string |
153 | | - { |
154 | | - return $this->website; |
155 | | - } |
156 | | - |
157 | | - /** |
158 | | - * Get the link to the website of an article. |
159 | | - * |
160 | | - * @param string|null $partnr * NULL for returning the URL with a placeholder for the part number |
161 | | - * * or the part number for returning the direct URL to the article |
162 | | - * |
163 | | - * @return string the link to the article |
164 | | - */ |
165 | | - public function getAutoProductUrl(?string $partnr = null): string |
166 | | - { |
167 | | - if (is_string($partnr)) { |
168 | | - return str_replace('%PARTNUMBER%', $partnr, $this->auto_product_url); |
169 | | - } |
170 | | - |
171 | | - return $this->auto_product_url; |
172 | | - } |
173 | | - |
174 | | - /******************************************************************************** |
175 | | - * |
176 | | - * Setters |
177 | | - * |
178 | | - *********************************************************************************/ |
179 | | - |
180 | | - /** |
181 | | - * Set the addres. |
182 | | - * |
183 | | - * @param string $new_address the new address (with "\n" as line break) |
184 | | - * |
185 | | - * @return $this |
186 | | - */ |
187 | | - public function setAddress(string $new_address): self |
188 | | - { |
189 | | - $this->address = $new_address; |
190 | | - |
191 | | - return $this; |
192 | | - } |
193 | | - |
194 | | - /** |
195 | | - * Set the phone number. |
196 | | - * |
197 | | - * @param string $new_phone_number the new phone number |
198 | | - * |
199 | | - * @return $this |
200 | | - */ |
201 | | - public function setPhoneNumber(string $new_phone_number): self |
202 | | - { |
203 | | - $this->phone_number = $new_phone_number; |
204 | | - |
205 | | - return $this; |
206 | | - } |
207 | | - |
208 | | - /** |
209 | | - * Set the fax number. |
210 | | - * |
211 | | - * @param string $new_fax_number the new fax number |
212 | | - * |
213 | | - * @return $this |
214 | | - */ |
215 | | - public function setFaxNumber(string $new_fax_number): self |
216 | | - { |
217 | | - $this->fax_number = $new_fax_number; |
218 | | - |
219 | | - return $this; |
220 | | - } |
221 | | - |
222 | | - /** |
223 | | - * Set the e-mail address. |
224 | | - * |
225 | | - * @param string $new_email_address the new e-mail address |
226 | | - * |
227 | | - * @return $this |
228 | | - */ |
229 | | - public function setEmailAddress(string $new_email_address): self |
230 | | - { |
231 | | - $this->email_address = $new_email_address; |
232 | | - |
233 | | - return $this; |
234 | | - } |
235 | | - |
236 | | - /** |
237 | | - * Set the website. |
238 | | - * |
239 | | - * @param string $new_website the new website |
240 | | - * |
241 | | - * @return $this |
242 | | - */ |
243 | | - public function setWebsite(string $new_website): self |
244 | | - { |
245 | | - $this->website = $new_website; |
246 | | - |
247 | | - return $this; |
248 | | - } |
249 | | - |
250 | | - /** |
251 | | - * Set the link to the website of an article. |
252 | | - * |
253 | | - * @param string $new_url the new URL with the placeholder %PARTNUMBER% for the part number |
254 | | - * |
255 | | - * @return $this |
256 | | - */ |
257 | | - public function setAutoProductUrl(string $new_url): self |
258 | | - { |
259 | | - $this->auto_product_url = $new_url; |
260 | | - |
261 | | - return $this; |
262 | | - } |
263 | 50 | } |
0 commit comments