Complex classes like Event often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Event, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
22 | class Event extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity |
||
23 | { |
||
24 | |||
25 | /** |
||
26 | * Title |
||
27 | * |
||
28 | * @var string |
||
29 | * @validate NotEmpty |
||
30 | */ |
||
31 | protected $title = ''; |
||
32 | |||
33 | /** |
||
34 | * Teaser |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $teaser = ''; |
||
39 | |||
40 | /** |
||
41 | * Description |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $description = ''; |
||
46 | |||
47 | /** |
||
48 | * Program/Schedule |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $program = ''; |
||
53 | |||
54 | /** |
||
55 | * Startdate and time |
||
56 | * |
||
57 | * @var \DateTime |
||
58 | */ |
||
59 | protected $startdate = null; |
||
60 | |||
61 | /** |
||
62 | * Enddate and time |
||
63 | * |
||
64 | * @var \DateTime |
||
65 | */ |
||
66 | protected $enddate = null; |
||
67 | |||
68 | /** |
||
69 | * Max participants |
||
70 | * |
||
71 | * @var int |
||
72 | */ |
||
73 | protected $maxParticipants = 0; |
||
74 | |||
75 | /** |
||
76 | * Max registrations per user |
||
77 | * |
||
78 | * @var int |
||
79 | */ |
||
80 | protected $maxRegistrationsPerUser = 1; |
||
81 | |||
82 | /** |
||
83 | * Price |
||
84 | * |
||
85 | * @var float |
||
86 | */ |
||
87 | protected $price = 0.0; |
||
88 | |||
89 | /** |
||
90 | * Currency |
||
91 | * |
||
92 | * @var string |
||
93 | */ |
||
94 | protected $currency = ''; |
||
95 | |||
96 | /** |
||
97 | * Enable payment |
||
98 | * |
||
99 | * @var bool |
||
100 | */ |
||
101 | protected $enablePayment = false; |
||
102 | |||
103 | /** |
||
104 | * Restrict payment methods |
||
105 | * |
||
106 | * @var bool |
||
107 | */ |
||
108 | protected $restrictPaymentMethods = false; |
||
109 | |||
110 | /** |
||
111 | * Selected payment methods |
||
112 | * |
||
113 | * @var string |
||
114 | */ |
||
115 | protected $selectedPaymentMethods = ''; |
||
116 | |||
117 | /** |
||
118 | * Category |
||
119 | * |
||
120 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category> |
||
121 | * @lazy |
||
122 | */ |
||
123 | protected $category = null; |
||
124 | |||
125 | /** |
||
126 | * Related |
||
127 | * |
||
128 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Event> |
||
129 | * @lazy |
||
130 | */ |
||
131 | protected $related; |
||
132 | |||
133 | /** |
||
134 | * Registration |
||
135 | * |
||
136 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Registration> |
||
137 | * @cascade remove |
||
138 | * @lazy |
||
139 | */ |
||
140 | protected $registration = null; |
||
141 | |||
142 | /** |
||
143 | * Registration deadline date |
||
144 | * |
||
145 | * @var \DateTime |
||
146 | */ |
||
147 | protected $registrationDeadline = null; |
||
148 | |||
149 | /** |
||
150 | * The image |
||
151 | * |
||
152 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
||
153 | * @lazy |
||
154 | */ |
||
155 | protected $image = null; |
||
156 | |||
157 | /** |
||
158 | * Additional files |
||
159 | * |
||
160 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
||
161 | * @lazy |
||
162 | */ |
||
163 | protected $files = null; |
||
164 | |||
165 | /** |
||
166 | * YouTube Embed code |
||
167 | * |
||
168 | * @var string |
||
169 | */ |
||
170 | protected $youtube = ''; |
||
171 | |||
172 | /** |
||
173 | * The Location |
||
174 | * |
||
175 | * @var \DERHANSEN\SfEventMgt\Domain\Model\Location |
||
176 | */ |
||
177 | protected $location = null; |
||
178 | |||
179 | /** |
||
180 | * Enable registration |
||
181 | * |
||
182 | * @var bool |
||
183 | */ |
||
184 | protected $enableRegistration = false; |
||
185 | |||
186 | /** |
||
187 | * Link |
||
188 | * |
||
189 | * @var string |
||
190 | */ |
||
191 | protected $link; |
||
192 | |||
193 | /** |
||
194 | * Top event |
||
195 | * |
||
196 | * @var bool |
||
197 | */ |
||
198 | protected $topEvent = false; |
||
199 | |||
200 | /** |
||
201 | * The additionalImage |
||
202 | * |
||
203 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
||
204 | * @lazy |
||
205 | */ |
||
206 | protected $additionalImage = null; |
||
207 | |||
208 | /** |
||
209 | * The organisator |
||
210 | * |
||
211 | * @var \DERHANSEN\SfEventMgt\Domain\Model\Organisator |
||
212 | */ |
||
213 | protected $organisator = null; |
||
214 | |||
215 | /** |
||
216 | * Notify admin |
||
217 | * |
||
218 | * @var bool |
||
219 | */ |
||
220 | protected $notifyAdmin = true; |
||
221 | |||
222 | /** |
||
223 | * Notify organisator |
||
224 | * |
||
225 | * @var bool |
||
226 | */ |
||
227 | protected $notifyOrganisator = false; |
||
228 | |||
229 | /** |
||
230 | * Enable cancel of registration |
||
231 | * |
||
232 | * @var bool |
||
233 | */ |
||
234 | protected $enableCancel = false; |
||
235 | |||
236 | /** |
||
237 | * Deadline for cancel |
||
238 | * |
||
239 | * @var \DateTime |
||
240 | */ |
||
241 | protected $cancelDeadline = null; |
||
242 | |||
243 | /** |
||
244 | * Unique e-mail check |
||
245 | * |
||
246 | * @var bool |
||
247 | */ |
||
248 | protected $uniqueEmailCheck = false; |
||
249 | |||
250 | /** |
||
251 | * Price options |
||
252 | * |
||
253 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\PriceOption> |
||
254 | * @cascade remove |
||
255 | * @lazy |
||
256 | */ |
||
257 | protected $priceOptions = null; |
||
258 | |||
259 | /** |
||
260 | * Constructor |
||
261 | */ |
||
262 | 148 | public function __construct() |
|
263 | { |
||
264 | 148 | $this->category = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
|
265 | 148 | $this->related = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
|
266 | 148 | $this->registration = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
|
267 | 148 | $this->image = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
|
268 | 148 | $this->files = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
|
269 | 148 | $this->additionalImage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
|
270 | 148 | $this->priceOptions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
|
271 | 148 | } |
|
272 | |||
273 | /** |
||
274 | * Returns the title |
||
275 | * |
||
276 | * @return string $title |
||
277 | */ |
||
278 | 9 | public function getTitle() |
|
279 | { |
||
280 | 9 | return $this->title; |
|
281 | } |
||
282 | |||
283 | /** |
||
284 | * Sets the title |
||
285 | * |
||
286 | * @param string $title Title |
||
287 | * |
||
288 | * @return void |
||
289 | */ |
||
290 | 1 | public function setTitle($title) |
|
291 | { |
||
292 | 1 | $this->title = $title; |
|
293 | 1 | } |
|
294 | |||
295 | /** |
||
296 | * Returns the teaser |
||
297 | * |
||
298 | * @return string |
||
299 | */ |
||
300 | 1 | public function getTeaser() |
|
301 | { |
||
302 | 1 | return $this->teaser; |
|
303 | } |
||
304 | |||
305 | /** |
||
306 | * Sets the teaser |
||
307 | * |
||
308 | * @param string $teaser Teaser |
||
309 | * |
||
310 | * @return void |
||
311 | */ |
||
312 | 1 | public function setTeaser($teaser) |
|
313 | { |
||
314 | 1 | $this->teaser = $teaser; |
|
315 | 1 | } |
|
316 | |||
317 | /** |
||
318 | * Returns the description |
||
319 | * |
||
320 | * @return string $description |
||
321 | */ |
||
322 | 1 | public function getDescription() |
|
323 | { |
||
324 | 1 | return $this->description; |
|
325 | } |
||
326 | |||
327 | /** |
||
328 | * Sets the description |
||
329 | * |
||
330 | * @param string $description Description |
||
331 | * |
||
332 | * @return void |
||
333 | */ |
||
334 | 1 | public function setDescription($description) |
|
335 | { |
||
336 | 1 | $this->description = $description; |
|
337 | 1 | } |
|
338 | |||
339 | /** |
||
340 | * Returns the program |
||
341 | * |
||
342 | * @return string $program |
||
343 | */ |
||
344 | 1 | public function getProgram() |
|
345 | { |
||
346 | 1 | return $this->program; |
|
347 | } |
||
348 | |||
349 | /** |
||
350 | * Sets the program |
||
351 | * |
||
352 | * @param string $program The program |
||
353 | * |
||
354 | * @return void |
||
355 | */ |
||
356 | 1 | public function setProgram($program) |
|
357 | { |
||
358 | 1 | $this->program = $program; |
|
359 | 1 | } |
|
360 | |||
361 | /** |
||
362 | * Returns the startdate |
||
363 | * |
||
364 | * @return \DateTime $startdate |
||
365 | */ |
||
366 | 9 | public function getStartdate() |
|
367 | { |
||
368 | 9 | return $this->startdate; |
|
369 | } |
||
370 | |||
371 | /** |
||
372 | * Sets the startdate |
||
373 | * |
||
374 | * @param \DateTime $startdate Startdate |
||
375 | * |
||
376 | * @return void |
||
377 | */ |
||
378 | 9 | public function setStartdate(\DateTime $startdate) |
|
379 | { |
||
380 | 9 | $this->startdate = $startdate; |
|
381 | 9 | } |
|
382 | |||
383 | /** |
||
384 | * Returns the enddate |
||
385 | * |
||
386 | * @return \DateTime $enddate |
||
387 | */ |
||
388 | 1 | public function getEnddate() |
|
389 | { |
||
390 | 1 | return $this->enddate; |
|
391 | } |
||
392 | |||
393 | /** |
||
394 | * Sets the enddate |
||
395 | * |
||
396 | * @param \DateTime $enddate Enddate |
||
397 | * |
||
398 | * @return void |
||
399 | */ |
||
400 | 1 | public function setEnddate(\DateTime $enddate) |
|
401 | { |
||
402 | 1 | $this->enddate = $enddate; |
|
403 | 1 | } |
|
404 | |||
405 | /** |
||
406 | * Returns the participants |
||
407 | * |
||
408 | * @return int $participants |
||
409 | */ |
||
410 | 9 | public function getMaxParticipants() |
|
411 | { |
||
412 | 9 | return $this->maxParticipants; |
|
413 | } |
||
414 | |||
415 | /** |
||
416 | * Sets the participants |
||
417 | * |
||
418 | * @param int $participants Participants |
||
419 | * |
||
420 | * @return void |
||
421 | */ |
||
422 | 8 | public function setMaxParticipants($participants) |
|
423 | { |
||
424 | 8 | $this->maxParticipants = $participants; |
|
425 | 8 | } |
|
426 | |||
427 | /** |
||
428 | * Returns the price |
||
429 | * |
||
430 | * @return float $price |
||
431 | */ |
||
432 | 1 | public function getPrice() |
|
433 | { |
||
434 | 1 | return $this->price; |
|
435 | } |
||
436 | |||
437 | /** |
||
438 | * Sets the price |
||
439 | * |
||
440 | * @param float $price Price |
||
441 | * |
||
442 | * @return void |
||
443 | */ |
||
444 | 3 | public function setPrice($price) |
|
445 | { |
||
446 | 3 | $this->price = $price; |
|
447 | 3 | } |
|
448 | |||
449 | /** |
||
450 | * Returns the currency |
||
451 | * |
||
452 | * @return string $currency |
||
453 | */ |
||
454 | 1 | public function getCurrency() |
|
455 | { |
||
456 | 1 | return $this->currency; |
|
457 | } |
||
458 | |||
459 | /** |
||
460 | * Sets the currency |
||
461 | * |
||
462 | * @param string $currency Currency |
||
463 | * |
||
464 | * @return void |
||
465 | */ |
||
466 | 1 | public function setCurrency($currency) |
|
467 | { |
||
468 | 1 | $this->currency = $currency; |
|
469 | 1 | } |
|
470 | |||
471 | /** |
||
472 | * Returns if payment is enabled |
||
473 | * |
||
474 | * @return boolean |
||
475 | */ |
||
476 | 4 | public function getEnablePayment() |
|
480 | |||
481 | /** |
||
482 | * Sets enablePayment |
||
483 | * |
||
484 | * @param boolean $enablePayment |
||
485 | * @return void |
||
486 | */ |
||
487 | 3 | public function setEnablePayment($enablePayment) |
|
488 | { |
||
489 | 3 | $this->enablePayment = $enablePayment; |
|
490 | 3 | } |
|
491 | |||
492 | /** |
||
493 | * Returns if payment methods should be restricted |
||
494 | * |
||
495 | * @return boolean |
||
496 | */ |
||
497 | 3 | public function getRestrictPaymentMethods() |
|
501 | |||
502 | /** |
||
503 | * Sets if payment methods should be restricted |
||
504 | * |
||
505 | * @param boolean $restrictPaymentMethods |
||
506 | * @return void |
||
507 | */ |
||
508 | 1 | public function setRestrictPaymentMethods($restrictPaymentMethods) |
|
509 | { |
||
510 | 1 | $this->restrictPaymentMethods = $restrictPaymentMethods; |
|
511 | 1 | } |
|
512 | |||
513 | /** |
||
514 | * Returns selected payment methods |
||
515 | * |
||
516 | * @return string |
||
517 | */ |
||
518 | 2 | public function getSelectedPaymentMethods() |
|
522 | |||
523 | /** |
||
524 | * Sets selected payment methods |
||
525 | * |
||
526 | * @param string $selectedPaymentMethods |
||
527 | * @return void |
||
528 | */ |
||
529 | 1 | public function setSelectedPaymentMethods($selectedPaymentMethods) |
|
530 | { |
||
531 | 1 | $this->selectedPaymentMethods = $selectedPaymentMethods; |
|
532 | 1 | } |
|
533 | |||
534 | /** |
||
535 | * Adds a Category |
||
536 | * |
||
537 | * @param \TYPO3\CMS\Extbase\Domain\Model\Category $category Category |
||
538 | * |
||
539 | * @return void |
||
540 | */ |
||
541 | 1 | public function addCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category) |
|
542 | { |
||
543 | 1 | $this->category->attach($category); |
|
544 | 1 | } |
|
545 | |||
546 | /** |
||
547 | * Removes a Category |
||
548 | * |
||
549 | * @param \TYPO3\CMS\Extbase\Domain\Model\Category $categoryToRemove The Category to be removed |
||
550 | * |
||
551 | * @return void |
||
552 | */ |
||
553 | 1 | public function removeCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $categoryToRemove) |
|
554 | { |
||
555 | 1 | $this->category->detach($categoryToRemove); |
|
556 | 1 | } |
|
557 | |||
558 | /** |
||
559 | * Returns the category |
||
560 | * |
||
561 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
562 | */ |
||
563 | 1 | public function getCategory() |
|
564 | { |
||
565 | 1 | return $this->category; |
|
566 | } |
||
567 | |||
568 | /** |
||
569 | * Sets the category |
||
570 | * |
||
571 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $category Category |
||
572 | * |
||
573 | * @return void |
||
574 | */ |
||
575 | 3 | public function setCategory(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $category) |
|
576 | { |
||
577 | 3 | $this->category = $category; |
|
578 | 3 | } |
|
579 | |||
580 | /** |
||
581 | * Returns related events |
||
582 | * |
||
583 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
584 | */ |
||
585 | 2 | public function getRelated() |
|
586 | { |
||
587 | 2 | return $this->related; |
|
588 | } |
||
589 | |||
590 | /** |
||
591 | * Sets related events |
||
592 | * |
||
593 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $related |
||
594 | * @return void |
||
595 | */ |
||
596 | 3 | public function setRelated($related) |
|
597 | { |
||
598 | 3 | $this->related = $related; |
|
599 | 3 | } |
|
600 | |||
601 | /** |
||
602 | * Adds a related event |
||
603 | * |
||
604 | * @param Event $event |
||
605 | * @return void |
||
606 | */ |
||
607 | 1 | public function addRelated(\DERHANSEN\SfEventMgt\Domain\Model\Event $event) |
|
608 | { |
||
609 | 1 | $this->related->attach($event); |
|
610 | 1 | } |
|
611 | |||
612 | /** |
||
613 | * Removes a related event |
||
614 | * |
||
615 | * @param Event $event |
||
616 | * @return void |
||
617 | */ |
||
618 | 1 | public function removeRelated(\DERHANSEN\SfEventMgt\Domain\Model\Event $event) |
|
619 | { |
||
620 | 1 | $this->related->detach($event); |
|
621 | 1 | } |
|
622 | |||
623 | /** |
||
624 | * Adds a Registration |
||
625 | * |
||
626 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration |
||
627 | * |
||
628 | * @return void |
||
629 | */ |
||
630 | 2 | public function addRegistration(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registration) |
|
631 | { |
||
632 | 2 | $this->registration->attach($registration); |
|
633 | 2 | } |
|
634 | |||
635 | /** |
||
636 | * Removes a Registration |
||
637 | * |
||
638 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove Registration |
||
639 | * |
||
640 | * @return void |
||
641 | */ |
||
642 | 1 | public function removeRegistration(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove) |
|
643 | { |
||
644 | 1 | $this->registration->detach($registrationToRemove); |
|
645 | 1 | } |
|
646 | |||
647 | /** |
||
648 | * Returns the Registration |
||
649 | * |
||
650 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration |
||
651 | */ |
||
652 | 7 | public function getRegistration() |
|
653 | { |
||
654 | 7 | return $this->registration; |
|
655 | } |
||
656 | |||
657 | /** |
||
658 | * Sets the Registration |
||
659 | * |
||
660 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration Registration |
||
661 | * |
||
662 | * @return void |
||
663 | */ |
||
664 | 4 | public function setRegistration(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration) |
|
665 | { |
||
666 | 4 | $this->registration = $registration; |
|
667 | 4 | } |
|
668 | |||
669 | /** |
||
670 | * Adds an image |
||
671 | * |
||
672 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $image Image |
||
673 | * |
||
674 | * @return void |
||
675 | */ |
||
676 | 1 | public function addImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $image) |
|
677 | { |
||
678 | 1 | $this->image->attach($image); |
|
679 | 1 | } |
|
680 | |||
681 | /** |
||
682 | * Removes an image |
||
683 | * |
||
684 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $imageToRemove Image |
||
685 | * |
||
686 | * @return void |
||
687 | */ |
||
688 | 1 | public function removeImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $imageToRemove) |
|
689 | { |
||
690 | 1 | $this->image->detach($imageToRemove); |
|
691 | 1 | } |
|
692 | |||
693 | /** |
||
694 | * Returns the image |
||
695 | * |
||
696 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $image |
||
697 | */ |
||
698 | 1 | public function getImage() |
|
699 | { |
||
700 | 1 | return $this->image; |
|
701 | } |
||
702 | |||
703 | /** |
||
704 | * Sets the image |
||
705 | * |
||
706 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $image Image |
||
707 | * |
||
708 | * @return void |
||
709 | */ |
||
710 | 3 | public function setImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $image) |
|
711 | { |
||
712 | 3 | $this->image = $image; |
|
713 | 3 | } |
|
714 | |||
715 | /** |
||
716 | * Adds a file |
||
717 | * |
||
718 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file File |
||
719 | * |
||
720 | * @return void |
||
721 | */ |
||
722 | 1 | public function addFiles(\TYPO3\CMS\Extbase\Domain\Model\FileReference $file) |
|
723 | { |
||
724 | 1 | $this->files->attach($file); |
|
725 | 1 | } |
|
726 | |||
727 | /** |
||
728 | * Removes a file |
||
729 | * |
||
730 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove File |
||
731 | * |
||
732 | * @return void |
||
733 | */ |
||
734 | 1 | public function removeFiles(\TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove) |
|
735 | { |
||
736 | 1 | $this->files->detach($fileToRemove); |
|
737 | 1 | } |
|
738 | |||
739 | /** |
||
740 | * Returns the files |
||
741 | * |
||
742 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $files |
||
743 | */ |
||
744 | 1 | public function getFiles() |
|
745 | { |
||
746 | 1 | return $this->files; |
|
747 | } |
||
748 | |||
749 | /** |
||
750 | * Sets the files |
||
751 | * |
||
752 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $files Files |
||
753 | * |
||
754 | * @return void |
||
755 | */ |
||
756 | 3 | public function setFiles(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $files) |
|
757 | { |
||
758 | 3 | $this->files = $files; |
|
759 | 3 | } |
|
760 | |||
761 | /** |
||
762 | * Returns YouTube embed code |
||
763 | * |
||
764 | * @return string |
||
765 | */ |
||
766 | 2 | public function getYoutube() |
|
767 | { |
||
768 | 2 | return $this->youtube; |
|
769 | } |
||
770 | |||
771 | /** |
||
772 | * Sets YouTube embed code |
||
773 | * |
||
774 | * @param string $youtube Youtube |
||
775 | * |
||
776 | * @return void |
||
777 | */ |
||
778 | 1 | public function setYoutube($youtube) |
|
779 | { |
||
780 | 1 | $this->youtube = $youtube; |
|
781 | 1 | } |
|
782 | |||
783 | /** |
||
784 | * Returns if the registration for this event is logically possible |
||
785 | * |
||
786 | * @return bool |
||
787 | */ |
||
788 | 8 | public function getRegistrationPossible() |
|
789 | { |
||
790 | 8 | $maxParticipantsNotReached = true; |
|
791 | 8 | if ($this->getMaxParticipants() > 0 && $this->getRegistration()->count() >= $this->maxParticipants) { |
|
792 | 1 | $maxParticipantsNotReached = false; |
|
793 | 1 | } |
|
794 | 8 | $deadlineNotReached = true; |
|
795 | 8 | if ($this->getRegistrationDeadline() != null && $this->getRegistrationDeadline() <= new \DateTime()) { |
|
796 | 1 | $deadlineNotReached = false; |
|
797 | 1 | } |
|
798 | 8 | return ($this->getStartdate() > new \DateTime()) && $maxParticipantsNotReached && |
|
799 | 8 | $this->getEnableRegistration() && $deadlineNotReached; |
|
800 | } |
||
801 | |||
802 | /** |
||
803 | * Returns the amount of free places |
||
804 | * |
||
805 | * @return int |
||
806 | */ |
||
807 | 2 | public function getFreePlaces() |
|
808 | { |
||
809 | 2 | return $this->maxParticipants - $this->getRegistration()->count(); |
|
810 | } |
||
811 | |||
812 | /** |
||
813 | * Sets the location |
||
814 | * |
||
815 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Location $location Location |
||
816 | * |
||
817 | * @return void |
||
818 | */ |
||
819 | 1 | public function setLocation($location) |
|
820 | { |
||
821 | 1 | $this->location = $location; |
|
822 | 1 | } |
|
823 | |||
824 | /** |
||
825 | * Returns the location |
||
826 | * |
||
827 | * @return \DERHANSEN\SfEventMgt\Domain\Model\Location |
||
828 | */ |
||
829 | 1 | public function getLocation() |
|
830 | { |
||
831 | 1 | return $this->location; |
|
832 | } |
||
833 | |||
834 | /** |
||
835 | * Sets enableRegistration |
||
836 | * |
||
837 | * @param bool $enableRegistration EnableRegistration |
||
838 | * |
||
839 | * @return void |
||
840 | */ |
||
841 | 8 | public function setEnableRegistration($enableRegistration) |
|
842 | { |
||
843 | 8 | $this->enableRegistration = $enableRegistration; |
|
844 | 8 | } |
|
845 | |||
846 | /** |
||
847 | * Returns if registration is enabled |
||
848 | * |
||
849 | * @return bool |
||
850 | */ |
||
851 | 7 | public function getEnableRegistration() |
|
855 | |||
856 | /** |
||
857 | * Sets the registration deadline |
||
858 | * |
||
859 | * @param \DateTime $registrationDeadline RegistrationDeadline |
||
860 | * |
||
861 | * @return void |
||
862 | */ |
||
863 | 3 | public function setRegistrationDeadline(\DateTime $registrationDeadline) |
|
864 | { |
||
865 | 3 | $this->registrationDeadline = $registrationDeadline; |
|
866 | 3 | } |
|
867 | |||
868 | /** |
||
869 | * Returns the registration deadline |
||
870 | * |
||
871 | * @return \DateTime |
||
872 | */ |
||
873 | 9 | public function getRegistrationDeadline() |
|
874 | { |
||
875 | 9 | return $this->registrationDeadline; |
|
876 | } |
||
877 | |||
878 | /** |
||
879 | * Sets the link |
||
880 | * |
||
881 | * @param string $link Link |
||
882 | * |
||
883 | * @return void |
||
884 | */ |
||
885 | 12 | public function setLink($link) |
|
886 | { |
||
887 | 12 | $this->link = $link; |
|
888 | 12 | } |
|
889 | |||
890 | /** |
||
891 | * Returns the link |
||
892 | * |
||
893 | * @return string |
||
894 | */ |
||
895 | 1 | public function getLink() |
|
899 | |||
900 | /** |
||
901 | * Returns the uri of the link |
||
902 | * |
||
903 | * @return string |
||
904 | */ |
||
905 | 1 | public function getLinkUrl() |
|
909 | |||
910 | /** |
||
911 | * Returns the target of the link |
||
912 | * |
||
913 | * @return string |
||
914 | */ |
||
915 | 1 | public function getLinkTarget() |
|
919 | |||
920 | /** |
||
921 | * Returns the title of the link |
||
922 | * |
||
923 | * @return string |
||
924 | */ |
||
925 | 1 | public function getLinkTitle() |
|
929 | |||
930 | /** |
||
931 | * Splits link to an array respection that a title with more than one word is |
||
932 | * surrounded by quotation marks. Returns part of the link for usage in fluid |
||
933 | * viewhelpers. |
||
934 | * |
||
935 | * @param int $part The part |
||
936 | * |
||
937 | * @return string |
||
938 | */ |
||
939 | 11 | public function getLinkPart($part) |
|
940 | { |
||
941 | 11 | $linkArray = str_getcsv($this->link, ' ', '"'); |
|
942 | 11 | $ret = ''; |
|
943 | 11 | if (count($linkArray) >= $part) { |
|
944 | 11 | $ret = $linkArray[$part]; |
|
945 | 11 | } |
|
946 | 11 | if ($ret === '-') { |
|
947 | 1 | $ret = ''; |
|
948 | 1 | } |
|
949 | 11 | return $ret; |
|
950 | } |
||
951 | |||
952 | /** |
||
953 | * Sets topEvent |
||
954 | * |
||
955 | * @param bool $topEvent TopEvent |
||
956 | * |
||
957 | * @return void |
||
958 | */ |
||
959 | 1 | public function setTopEvent($topEvent) |
|
960 | { |
||
961 | 1 | $this->topEvent = $topEvent; |
|
962 | 1 | } |
|
963 | |||
964 | /** |
||
965 | * Returns if topEvent is checked |
||
966 | * |
||
967 | * @return bool |
||
968 | */ |
||
969 | 1 | public function getTopEvent() |
|
970 | { |
||
971 | 1 | return $this->topEvent; |
|
972 | } |
||
973 | |||
974 | /** |
||
975 | * Returns max regisrations per user |
||
976 | * |
||
977 | * @return int |
||
978 | */ |
||
979 | 2 | public function getMaxRegistrationsPerUser() |
|
980 | { |
||
981 | 2 | return $this->maxRegistrationsPerUser; |
|
982 | } |
||
983 | |||
984 | /** |
||
985 | * Sets max registrations per user |
||
986 | * |
||
987 | * @param int $maxRegistrationsPerUser MaxRegistrationsPerUser |
||
988 | * |
||
989 | * @return void |
||
990 | */ |
||
991 | 1 | public function setMaxRegistrationsPerUser($maxRegistrationsPerUser) |
|
992 | { |
||
993 | 1 | $this->maxRegistrationsPerUser = $maxRegistrationsPerUser; |
|
994 | 1 | } |
|
995 | |||
996 | |||
997 | /** |
||
998 | * Adds an additionalImage |
||
999 | * |
||
1000 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage The Image |
||
1001 | * |
||
1002 | * @return void |
||
1003 | */ |
||
1004 | 1 | public function addAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage) |
|
1005 | { |
||
1006 | 1 | $this->additionalImage->attach($additionalImage); |
|
1007 | 1 | } |
|
1008 | |||
1009 | /** |
||
1010 | * Removes an additionalImage |
||
1011 | * |
||
1012 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove The Image |
||
1013 | * |
||
1014 | * @return void |
||
1015 | */ |
||
1016 | 1 | public function removeAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove) |
|
1017 | { |
||
1018 | 1 | $this->additionalImage->detach($additionalImageToRemove); |
|
1019 | 1 | } |
|
1020 | |||
1021 | /** |
||
1022 | * Returns the additionalImage |
||
1023 | * |
||
1024 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage |
||
1025 | */ |
||
1026 | 1 | public function getAdditionalImage() |
|
1027 | { |
||
1028 | 1 | return $this->additionalImage; |
|
1029 | } |
||
1030 | |||
1031 | /** |
||
1032 | * Sets the additionalImage |
||
1033 | * |
||
1034 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage The Image |
||
1035 | * |
||
1036 | * @return void |
||
1037 | */ |
||
1038 | 3 | public function setAdditionalImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage) |
|
1039 | { |
||
1040 | 3 | $this->additionalImage = $additionalImage; |
|
1041 | 3 | } |
|
1042 | |||
1043 | /** |
||
1044 | * Returns the organisator |
||
1045 | * |
||
1046 | * @return Organisator |
||
1047 | */ |
||
1048 | 4 | public function getOrganisator() |
|
1049 | { |
||
1050 | 4 | return $this->organisator; |
|
1051 | } |
||
1052 | |||
1053 | /** |
||
1054 | * Sets the organisator |
||
1055 | * |
||
1056 | * @param Organisator $organisator The organisator |
||
1057 | * |
||
1058 | * @return void |
||
1059 | */ |
||
1060 | 4 | public function setOrganisator($organisator) |
|
1061 | { |
||
1062 | 4 | $this->organisator = $organisator; |
|
1063 | 4 | } |
|
1064 | |||
1065 | /** |
||
1066 | * Returns notifyAdmin |
||
1067 | * |
||
1068 | * @return bool |
||
1069 | */ |
||
1070 | 17 | public function getNotifyAdmin() |
|
1071 | { |
||
1072 | 17 | return $this->notifyAdmin; |
|
1073 | } |
||
1074 | |||
1075 | /** |
||
1076 | * Sets notifyAdmin |
||
1077 | * |
||
1078 | * @param bool $notifyAdmin NotifyAdmin |
||
1079 | * |
||
1080 | * @return void |
||
1081 | */ |
||
1082 | 7 | public function setNotifyAdmin($notifyAdmin) |
|
1083 | { |
||
1084 | 7 | $this->notifyAdmin = $notifyAdmin; |
|
1085 | 7 | } |
|
1086 | |||
1087 | /** |
||
1088 | * Returns if notifyAdmin is set |
||
1089 | * |
||
1090 | * @return bool |
||
1091 | */ |
||
1092 | 17 | public function getNotifyOrganisator() |
|
1093 | { |
||
1094 | 17 | return $this->notifyOrganisator; |
|
1095 | } |
||
1096 | |||
1097 | /** |
||
1098 | * Sets notifyOrganisator |
||
1099 | * |
||
1100 | * @param bool $notifyOrganisator NotifyOrganisator |
||
1101 | * |
||
1102 | * @return void |
||
1103 | */ |
||
1104 | 7 | public function setNotifyOrganisator($notifyOrganisator) |
|
1105 | { |
||
1106 | 7 | $this->notifyOrganisator = $notifyOrganisator; |
|
1107 | 7 | } |
|
1108 | |||
1109 | /** |
||
1110 | * Sets enableCancel |
||
1111 | * |
||
1112 | * @param bool $enableCancel EnableCancel |
||
1113 | * |
||
1114 | * @return void |
||
1115 | */ |
||
1116 | 1 | public function setEnableCancel($enableCancel) |
|
1120 | |||
1121 | /** |
||
1122 | * Returns if registration can be canceled |
||
1123 | * |
||
1124 | * @return bool |
||
1125 | */ |
||
1126 | 2 | public function getEnableCancel() |
|
1127 | { |
||
1128 | 2 | return $this->enableCancel; |
|
1129 | } |
||
1130 | |||
1131 | /** |
||
1132 | * Sets the cancel deadline |
||
1133 | * |
||
1134 | * @param \DateTime $cancelDeadline RegistrationDeadline |
||
1135 | * |
||
1136 | * @return void |
||
1137 | */ |
||
1138 | 1 | public function setCancelDeadline(\DateTime $cancelDeadline) |
|
1139 | { |
||
1140 | 1 | $this->cancelDeadline = $cancelDeadline; |
|
1141 | 1 | } |
|
1142 | |||
1143 | /** |
||
1144 | * Returns the cancel deadline |
||
1145 | * |
||
1146 | * @return \DateTime |
||
1147 | */ |
||
1148 | 2 | public function getCancelDeadline() |
|
1149 | { |
||
1150 | 2 | return $this->cancelDeadline; |
|
1151 | } |
||
1152 | |||
1153 | /** |
||
1154 | * Returns uniqueEmailCheck |
||
1155 | * |
||
1156 | * @return boolean |
||
1157 | */ |
||
1158 | 2 | public function getUniqueEmailCheck() |
|
1159 | { |
||
1160 | 2 | return $this->uniqueEmailCheck; |
|
1161 | } |
||
1162 | |||
1163 | /** |
||
1164 | * Sets UniqueEmailCheck |
||
1165 | * |
||
1166 | * @param boolean $uniqueEmailCheck |
||
1167 | * @return void |
||
1168 | */ |
||
1169 | 1 | public function setUniqueEmailCheck($uniqueEmailCheck) |
|
1170 | { |
||
1171 | 1 | $this->uniqueEmailCheck = $uniqueEmailCheck; |
|
1172 | 1 | } |
|
1173 | |||
1174 | /** |
||
1175 | * Returns price options |
||
1176 | * |
||
1177 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
1178 | */ |
||
1179 | 5 | public function getPriceOptions() |
|
1180 | { |
||
1181 | 5 | return $this->priceOptions; |
|
1182 | } |
||
1183 | |||
1184 | /** |
||
1185 | * Sets price options |
||
1186 | * |
||
1187 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $priceOptions |
||
1188 | * @return void |
||
1189 | */ |
||
1190 | 3 | public function setPriceOptions($priceOptions) |
|
1191 | { |
||
1192 | 3 | $this->priceOptions = $priceOptions; |
|
1193 | 3 | } |
|
1194 | |||
1195 | /** |
||
1196 | * Adds a price option |
||
1197 | * |
||
1198 | * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option |
||
1199 | * |
||
1200 | * @return void |
||
1201 | */ |
||
1202 | 3 | public function addPriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption) |
|
1206 | |||
1207 | /** |
||
1208 | * Removes a Registration |
||
1209 | * |
||
1210 | * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option |
||
1211 | * |
||
1212 | * @return void |
||
1213 | */ |
||
1214 | 1 | public function removePriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption) |
|
1218 | |||
1219 | /** |
||
1220 | * Returns all active price options sorted by date ASC |
||
1221 | * |
||
1222 | * @return array |
||
1223 | */ |
||
1224 | 3 | public function getActivePriceOptions() |
|
1238 | |||
1239 | /** |
||
1240 | * Returns the current price of the event respecting possible price options |
||
1241 | * |
||
1242 | * @return float |
||
1243 | */ |
||
1244 | 2 | public function getCurrentPrice() |
|
1255 | } |