Completed
Push — master ( cba1df...96b309 )
by Tim
02:17
created

Event::setOrganizerLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Event (Default) for the calendarize function.
5
 */
6
declare(strict_types=1);
7
8
namespace HDNET\Calendarize\Domain\Model;
9
10
use HDNET\Calendarize\Features\FeedInterface;
11
use HDNET\Calendarize\Features\KeSearchIndexInterface;
12
use HDNET\Calendarize\Features\SpeakingUrlInterface;
13
use TYPO3\CMS\Extbase\Domain\Model\Category;
14
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
15
16
/**
17
 * Event (Default) for the calendarize function.
18
 *
19
 * @db
20
 * @smartExclude Workspaces
21
 */
22
class Event extends AbstractModel implements FeedInterface, SpeakingUrlInterface, KeSearchIndexInterface
23
{
24
    /**
25
     * Title.
26
     *
27
     * @var string
28
     * @db
29
     */
30
    protected $title;
31
32
    /**
33
     * Abstract / Teaser.
34
     *
35
     * @var string
36
     * @db
37
     */
38
    protected $abstract;
39
40
    /**
41
     * Description.
42
     *
43
     * @var string
44
     * @db
45
     * @enableRichText
46
     */
47
    protected $description;
48
49
    /**
50
     * Location.
51
     *
52
     * @var string
53
     * @db
54
     */
55
    protected $location;
56
57
    /**
58
     * Location link.
59
     *
60
     * @var string
61
     * @db
62
     */
63
    protected $locationLink;
64
65
    /**
66
     * Organizer.
67
     *
68
     * @var string
69
     * @db
70
     */
71
    protected $organizer;
72
73
    /**
74
     * Organizer link.
75
     *
76
     * @var string
77
     * @db
78
     */
79
    protected $organizerLink;
80
81
    /**
82
     * Import ID if the item is based on an ICS structure.
83
     *
84
     * @var string
85
     * @db
86
     */
87
    protected $importId;
88
89
    /**
90
     * Images.
91
     *
92
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
93
     * @db
94
     */
95
    protected $images;
96
97
    /**
98
     * Downloads.
99
     *
100
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
101
     * @db
102
     */
103
    protected $downloads;
104
105
    /**
106
     * Relation field. It is just used by the importer of the default events.
107
     * You do not need this field, if you don't use the default Event.
108
     *
109
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\HDNET\Calendarize\Domain\Model\Configuration>
110
     */
111
    protected $calendarize;
112
113
    /**
114
     * Categories.
115
     *
116
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category>
117
     */
118
    protected $categories;
119
120
    /**
121
     * @var bool
122
     */
123
    protected $hidden = false;
124
125
    /**
126
     * Build up the object.
127
     */
128
    public function __construct()
129
    {
130
        $this->calendarize = new ObjectStorage();
131
        $this->images = new ObjectStorage();
132
        $this->downloads = new ObjectStorage();
133
        $this->categories = new ObjectStorage();
134
    }
135
136
    /**
137
     * Get title.
138
     *
139
     * @return string
140
     */
141
    public function getTitle()
142
    {
143
        return $this->title;
144
    }
145
146
    /**
147
     * Set title.
148
     *
149
     * @param string $title
150
     */
151
    public function setTitle($title)
152
    {
153
        $this->title = $title;
154
    }
155
156
    /**
157
     * Get abstract.
158
     *
159
     * @return string
160
     */
161
    public function getAbstract()
162
    {
163
        return $this->abstract;
164
    }
165
166
    /**
167
     * Set abstract.
168
     *
169
     * @param string $abstract
170
     */
171
    public function setAbstract($abstract)
172
    {
173
        $this->abstract = $abstract;
174
    }
175
176
    /**
177
     * Get description.
178
     *
179
     * @return string
180
     */
181
    public function getDescription()
182
    {
183
        return $this->description;
184
    }
185
186
    /**
187
     * Set description.
188
     *
189
     * @param string $description
190
     */
191
    public function setDescription($description)
192
    {
193
        $this->description = $description;
194
    }
195
196
    /**
197
     * Get downloads.
198
     *
199
     * @return ObjectStorage
200
     */
201
    public function getDownloads()
202
    {
203
        return $this->downloads;
204
    }
205
206
    /**
207
     * Set downloads.
208
     *
209
     * @param ObjectStorage $downloads
210
     */
211
    public function setDownloads($downloads)
212
    {
213
        $this->downloads = $downloads;
214
    }
215
216
    /**
217
     * Get images.
218
     *
219
     * @return ObjectStorage
220
     */
221
    public function getImages()
222
    {
223
        return $this->images;
224
    }
225
226
    /**
227
     * Set images.
228
     *
229
     * @param ObjectStorage $images
230
     */
231
    public function setImages($images)
232
    {
233
        $this->images = $images;
234
    }
235
236
    /**
237
     * Get Import ID.
238
     *
239
     * @return string
240
     */
241
    public function getImportId()
242
    {
243
        return $this->importId;
244
    }
245
246
    /**
247
     * Set import ID.
248
     *
249
     * @param string $importId
250
     */
251
    public function setImportId($importId)
252
    {
253
        $this->importId = $importId;
254
    }
255
256
    /**
257
     * Get calendarize.
258
     *
259
     * @return ObjectStorage
260
     */
261
    public function getCalendarize()
262
    {
263
        return $this->calendarize;
264
    }
265
266
    /**
267
     * Set calendarize.
268
     *
269
     * @param ObjectStorage $calendarize
270
     */
271
    public function setCalendarize($calendarize)
272
    {
273
        $this->calendarize = $calendarize;
274
    }
275
276
    /**
277
     * Add one calendarize configuration.
278
     *
279
     * @param Configuration $calendarize
280
     */
281
    public function addCalendarize($calendarize)
282
    {
283
        $this->calendarize->attach($calendarize);
284
    }
285
286
    /**
287
     * Get the feed title.
288
     *
289
     * @return string
290
     */
291
    public function getFeedTitle(): string
292
    {
293
        return (string) $this->getTitle();
294
    }
295
296
    /**
297
     * Get the feed abstract.
298
     *
299
     * @return string
300
     */
301
    public function getFeedAbstract(): string
302
    {
303
        return (string) $this->getFeedContent();
304
    }
305
306
    /**
307
     * Get the feed content.
308
     *
309
     * @return string
310
     */
311
    public function getFeedContent(): string
312
    {
313
        return (string) $this->getDescription();
314
    }
315
316
    /**
317
     * Get the feed location.
318
     *
319
     * @return string
320
     */
321
    public function getFeedLocation(): string
322
    {
323
        return (string) $this->getLocation();
324
    }
325
326
    /**
327
     * Get the base for the realurl alias.
328
     *
329
     * @return string
330
     */
331
    public function getRealUrlAliasBase(): string
332
    {
333
        return (string) $this->getTitle();
334
    }
335
336
    /**
337
     * Adds a Category.
338
     *
339
     * @param Category $category
340
     */
341
    public function addCategory(Category $category)
342
    {
343
        $this->categories->attach($category);
344
    }
345
346
    /**
347
     * Removes a Category.
348
     *
349
     * @param Category $categoryToRemove The Category to be removed
350
     */
351
    public function removeCategory(Category $categoryToRemove)
352
    {
353
        $this->categories->detach($categoryToRemove);
354
    }
355
356
    /**
357
     * Returns the categories.
358
     *
359
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $categories
360
     */
361
    public function getCategories()
362
    {
363
        return $this->categories;
364
    }
365
366
    /**
367
     * Sets the categories.
368
     *
369
     * @param ObjectStorage $categories
370
     */
371
    public function setCategories(ObjectStorage $categories)
372
    {
373
        $this->categories = $categories;
374
    }
375
376
    /**
377
     * Get the title.
378
     *
379
     * @param Index $index
380
     *
381
     * @return string
382
     */
383
    public function getKeSearchTitle(Index $index): string
384
    {
385
        return (string) $this->getTitle() . ' - ' . $index->getStartDate()
386
                ->format('d.m.Y');
387
    }
388
389
    /**
390
     * Get the abstract.
391
     *
392
     * @param Index $index
393
     *
394
     * @return string
395
     */
396
    public function getKeSearchAbstract(Index $index): string
397
    {
398
        return (string) $this->getDescription();
399
    }
400
401
    /**
402
     * Get the content.
403
     *
404
     * @param Index $index
405
     *
406
     * @return string
407
     */
408
    public function getKeSearchContent(Index $index): string
409
    {
410
        return (string) $this->getDescription();
411
    }
412
413
    /**
414
     * Get the tags.
415
     *
416
     * @param Index $index
417
     *
418
     * @return string Comma separated list of tags, e.g. '#syscat1#,#syscat2#'
419
     */
420
    public function getKeSearchTags(Index $index): string
421
    {
422
        static $keSearchTags = [];
423
        if (empty($keSearchTags)) {
424
            foreach ($this->getCategories() as $category) {
425
                $keSearchTags[] = "#syscat{$category->getUid()}#";
426
            }
427
        }
428
429
        return \implode(',', $keSearchTags);
430
    }
431
432
    /**
433
     * Get location.
434
     *
435
     * @return string
436
     */
437
    public function getLocation()
438
    {
439
        return $this->location;
440
    }
441
442
    /**
443
     * Set location.
444
     *
445
     * @param string $location
446
     */
447
    public function setLocation($location)
448
    {
449
        $this->location = $location;
450
    }
451
452
    /**
453
     * Get orginzer.
454
     *
455
     * @return string
456
     */
457
    public function getOrganizer()
458
    {
459
        return $this->organizer;
460
    }
461
462
    /**
463
     * Set organizer.
464
     *
465
     * @param string $organizer
466
     */
467
    public function setOrganizer($organizer)
468
    {
469
        $this->organizer = $organizer;
470
    }
471
472
    /**
473
     * @return bool
474
     */
475
    public function isHidden()
476
    {
477
        return $this->hidden;
478
    }
479
480
    /**
481
     * @param bool $hidden
482
     */
483
    public function setHidden($hidden)
484
    {
485
        $this->hidden = $hidden;
486
    }
487
488
    /**
489
     * @return string
490
     */
491
    public function getLocationLink()
492
    {
493
        return $this->locationLink;
494
    }
495
496
    /**
497
     * @param string $locationLink
498
     */
499
    public function setLocationLink($locationLink)
500
    {
501
        $this->locationLink = $locationLink;
502
    }
503
504
    /**
505
     * @return string
506
     */
507
    public function getOrganizerLink()
508
    {
509
        return $this->organizerLink;
510
    }
511
512
    /**
513
     * @param string $organizerLink
514
     */
515
    public function setOrganizerLink($organizerLink)
516
    {
517
        $this->organizerLink = $organizerLink;
518
    }
519
520
521
}
522