Passed
Push — master ( e3d782...6a016e )
by Ralf
15:44 queued 13s
created

MetadataGroup::setRequiredGroups()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace EWW\Dpf\Domain\Model;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
/**
18
 * MetadataGroup
19
 */
20
class MetadataGroup extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity implements MetadataMandatoryInterface
21
{
22
23
    /**
24
     * name
25
     *
26
     * @var string
27
     */
28
    protected $name = '';
29
30
    /**
31
     * displayName
32
     *
33
     * @var string
34
     */
35
    protected $displayName = '';
36
37
    /**
38
     * mandatory
39
     *
40
     * @var string
41
     */
42
    protected $mandatory = '';
43
44
    /**
45
     * mapping
46
     *
47
     * @var string
48
     */
49
    protected $mapping = '';
50
51
    /**
52
     * mappingForReading
53
     *
54
     * @var string
55
     */
56
    protected $mappingForReading = '';
57
58
    /**
59
     * modsExtensionMapping
60
     *
61
     * @var string
62
     */
63
    protected $modsExtensionMapping = '';
64
65
    /**
66
     * modsExtensionReference
67
     *
68
     * @var string
69
     */
70
    protected $modsExtensionReference = '';
71
72
    /**
73
     * maxIteration
74
     *
75
     * @var integer
76
     */
77
    protected $maxIteration = 0;
78
79
    /**
80
     * metadataObject
81
     *
82
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\MetadataObject>
83
     * @TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")
84
     */
85
    protected $metadataObject = null;
86
87
    /**
88
     * accessRestrictionRoles
89
     *
90
     * @var string
91
     */
92
    protected $accessRestrictionRoles = '';
93
94
    /**
95
     * infoText
96
     *
97
     * @var string
98
     */
99
    protected $infoText;
100
101
    /**
102
     * group type
103
     * @var string
104
     */
105
    protected $groupType = '';
106
107
    /**
108
     * JSON mapping
109
     *
110
     * @var string
111
     */
112
    protected $jsonMapping = '';
113
114
    /**
115
     * @var string
116
     */
117
    protected $optionalGroups = '';
118
119
    /**
120
     * @var string
121
     */
122
    protected $requiredGroups = '';
123
124
    /**
125
     * __construct
126
     */
127
    public function __construct()
128
    {
129
        //Do not remove the next line: It would break the functionality
130
        $this->initStorageObjects();
131
    }
132
133
    /**
134
     * Initializes all ObjectStorage properties
135
     *
136
     * @return void
137
     */
138
    protected function initStorageObjects()
139
    {
140
        $this->metadataObject = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
141
    }
142
143
    /**
144
     * Returns the name
145
     *
146
     * @return string $name
147
     */
148
    public function getName()
149
    {
150
        return $this->name;
151
    }
152
153
    /**
154
     * Sets the name
155
     *
156
     * @param string $name
157
     * @return void
158
     */
159
    public function setName($name)
160
    {
161
        $this->name = $name;
162
    }
163
164
    /**
165
     * Returns the displayName
166
     *
167
     * @return string $displayName
168
     */
169
    public function getDisplayName()
170
    {
171
        return $this->displayName;
172
    }
173
174
    /**
175
     * Sets the displayName
176
     *
177
     * @param string $displayName
178
     * @return void
179
     */
180
    public function setDisplayName($displayName)
181
    {
182
        $this->displayName = $displayName;
183
    }
184
185
    /**
186
     * Returns the mandatory
187
     *
188
     * @return string $mandatory
189
     */
190
    public function getMandatory()
191
    {
192
        return $this->mandatory;
193
    }
194
195
    /**
196
     * Sets the mandatory
197
     *
198
     * @param string $mandatory
199
     * @return void
200
     */
201
    public function setMandatory($mandatory)
202
    {
203
        $this->mandatory = $mandatory;
204
    }
205
206
    /**
207
     * Returns the mapping
208
     *
209
     * @return string $mapping
210
     */
211
    public function getMapping()
212
    {
213
        return $this->mapping;
214
    }
215
216
    /**
217
     * Sets the mapping
218
     *
219
     * @param string $mapping
220
     * @return void
221
     */
222
    public function setMapping($mapping)
223
    {
224
        $this->mapping = $mapping;
225
    }
226
227
    /**
228
     * Returns the mappingForReading
229
     *
230
     * @return string $mappingForReading
231
     */
232
    public function getMappingForReading()
233
    {
234
        return $this->mappingForReading;
235
    }
236
237
    /**
238
     * Sets the mappingForReading
239
     *
240
     * @param string $mappingForReading
241
     * @return void
242
     */
243
    public function setMappingForReading($mappingForReading)
244
    {
245
        $this->mappingForReading = $mappingForReading;
246
    }
247
248
    /**
249
     * Checks if a mapping for reading is defined
250
     *
251
     * @return bool
252
     */
253
    public function hasMappingForReading()
254
    {
255
        $mapping = trim($this->mappingForReading);
256
        return !empty($mapping);
257
    }
258
259
    /**
260
     * Returns the relative mapping
261
     *
262
     * @param $mapping
263
     * @return string $relativeMapping
264
     */
265
    protected function relativeMapping($mapping)
266
    {
267
        return trim($mapping, " /");
268
    }
269
270
    /**
271
     * Returns the relative mapping for writing
272
     *
273
     * @return string $relativeMappingForWriting
274
     */
275
    public function getRelativeMapping()
276
    {
277
        return $this->relativeMapping($this->mapping);
278
    }
279
280
    /**
281
     * Returns the relative mapping for reading
282
     *
283
     * @return string $relativeMappingForReading
284
     */
285
    public function getRelativeMappingForReading()
286
    {
287
        return $this->relativeMapping($this->mappingForReading);
288
    }
289
290
    /**
291
     * Returns the absolute mapping for writing
292
     *
293
     * @return string $absoluteMappingForWriting
294
     */
295
    public function getAbsoluteMapping()
296
    {
297
        return "/data/" . $this->getRelativeMapping();
298
    }
299
300
    /**
301
     * Returns the absolute mapping for reading
302
     *
303
     * @return string $absoluteMappingForReading
304
     */
305
    public function getAbsoluteMappingForReading()
306
    {
307
        return "/data/" . $this->getRelativeMappingForReading();
308
    }
309
310
    /**
311
     * Returns the modsExtensionMapping
312
     *
313
     * @return string $modsExtensionMapping
314
     */
315
    public function getModsExtensionMapping()
316
    {
317
        return $this->modsExtensionMapping;
318
    }
319
320
    /**
321
     * Sets the modsExtensionMapping
322
     *
323
     * @param string $modsExtensionMapping
324
     * @return void
325
     */
326
    public function setModsExtensionMapping($modsExtensionMapping)
327
    {
328
        $this->modsExtensionMapping = $modsExtensionMapping;
329
    }
330
331
    /**
332
     * Returns the relative mods extension mapping
333
     *
334
     * @return string $relativeModsExtensionMapping
335
     */
336
    public function getRelativeModsExtensionMapping()
337
    {
338
//        $modsRegExp = "/^.*?mods:mods/i";
339
//        $mapping    = preg_replace($modsRegExp, "", $this->modsExtensionMapping);
340
        return trim($this->modsExtensionMapping, " /");
341
    }
342
343
    /**
344
     * Returns the absolute mods extension mapping
345
     *
346
     * @return string $absoluteModsExtensionMapping
347
     */
348
    public function getAbsoluteModsExtensionMapping()
349
    {
350
        return "/data/" . $this->getRelativeModsExtensionMapping();
351
    }
352
353
    /**
354
     * Sets the modsExtensionReference
355
     *
356
     * @param string $modsExtensionReference
357
     * @return void
358
     */
359
    public function setModsExtensionReference($modsExtensionReference)
360
    {
361
        $this->modsExtensionReference = $modsExtensionReference;
362
    }
363
364
    /**
365
     * Returns the modsExtensionReference
366
     *
367
     * @return string $modsExtensionReference
368
     */
369
    public function getModsExtensionReference()
370
    {
371
        return $this->modsExtensionReference;
372
    }
373
374
    /**
375
     * Returns the maxIteration
376
     *
377
     * @return integer $maxIteration
378
     */
379
    public function getMaxIteration()
380
    {
381
        return $this->maxIteration;
382
    }
383
384
    /**
385
     * Sets the maxIteration
386
     *
387
     * @param integer $maxIteration
388
     * @return void
389
     */
390
    public function setMaxIteration($maxIteration)
391
    {
392
        $this->maxIteration = $maxIteration;
393
    }
394
395
    /**
396
     * Adds a MetadataObject
397
     *
398
     * @param \EWW\Dpf\Domain\Model\MetadataObject $metadataObject
399
     * @return void
400
     */
401
    public function addMetadataObject(\EWW\Dpf\Domain\Model\MetadataObject $metadataObject)
402
    {
403
        $this->metadataObject->attach($metadataObject);
404
    }
405
406
    /**
407
     * Removes a MetadataObject
408
     *
409
     * @param \EWW\Dpf\Domain\Model\MetadataObject $metadataObjectToRemove The MetadataObject to be removed
410
     * @return void
411
     */
412
    public function removeMetadataObject(\EWW\Dpf\Domain\Model\MetadataObject $metadataObjectToRemove)
413
    {
414
        $this->metadataObject->detach($metadataObjectToRemove);
415
    }
416
417
    /**
418
     * Returns the metadataObject
419
     *
420
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\MetadataObject> $metadataObject
421
     */
422
    public function getMetadataObject()
423
    {
424
        return $this->metadataObject;
425
    }
426
427
    /**
428
     * Sets the metadataObject
429
     *
430
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\MetadataObject> $metadataObject
431
     * @return void
432
     */
433
    public function setMetadataObject(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $metadataObject)
434
    {
435
        $this->metadataObject = $metadataObject;
436
    }
437
438
    /**
439
     * Alias for function getMetadataObject()
440
     *
441
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\EWW\Dpf\Domain\Model\MetadataObject> $metadataObject
442
     */
443
    public function getChildren()
444
    {
445
        return $this->getMetadataObject();
446
    }
447
448
    /**
449
     * Returns the accessRestrictionRoles
450
     *
451
     * @return array $accessRestrictionRoles
452
     */
453
    public function getAccessRestrictionRoles()
454
    {
455
        if ($this->accessRestrictionRoles) {
456
            return array_map('trim', explode(',', $this->accessRestrictionRoles));
457
        } else {
458
            return array();
459
        }
460
    }
461
462
    /**
463
     * Sets the accessRestrictionRoles
464
     *
465
     * @param array $accessRestrictionRoles
466
     * @return void
467
     */
468
    public function setAccessRestrictionRoles($accessRestrictionRoles)
469
    {
470
        $this->accessRestrictionRoles = implode(',', $accessRestrictionRoles);
471
    }
472
473
    /**
474
     * Returns the infoText
475
     *
476
     * @return string $infoText
477
     */
478
    public function getInfoText()
479
    {
480
        return $this->infoText;
481
    }
482
483
    /**
484
     * Sets the infoText
485
     *
486
     * @param string $infoText
487
     * @return void
488
     */
489
    public function setInfoText($infoText)
490
    {
491
        $this->infoText = $infoText;
492
    }
493
494
    /**
495
     * @return string
496
     */
497
    public function getGroupType(): string
498
    {
499
        return $this->groupType;
500
    }
501
502
    /**
503
     * @param string $groupType
504
     */
505
    public function setGroupType(string $groupType)
506
    {
507
        $this->groupType = $groupType;
508
    }
509
510
    /**
511
     * Gets the jsonMapping
512
     *
513
     * @return string
514
     */
515
    public function getJsonMapping(): string
516
    {
517
        return $this->jsonMapping;
518
    }
519
520
    /**
521
     * Sets the jsonMapping
522
     *
523
     * @param string $jsonMapping
524
     */
525
    public function setJsonMapping(string $jsonMapping): void
526
    {
527
        $this->jsonMapping = $jsonMapping;
528
    }
529
530
    /**
531
     * @return string
532
     */
533
    public function getOptionalGroups(): string
534
    {
535
        return $this->optionalGroups;
536
    }
537
538
    /**
539
     * @param string $optionalGroups
540
     */
541
    public function setOptionalGroups(string $optionalGroups): void
542
    {
543
        $this->optionalGroups = $optionalGroups;
544
    }
545
546
    /**
547
     * @return string
548
     */
549
    public function getRequiredGroups(): string
550
    {
551
        return $this->requiredGroups;
552
    }
553
554
    /**
555
     * @param string $requiredGroups
556
     */
557
    public function setRequiredGroups(string $requiredGroups): void
558
    {
559
        $this->requiredGroups = $requiredGroups;
560
    }
561
562
563
}
564