|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS. |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace DERHANSEN\SfEventMgt\Domain\Model\Dto; |
|
13
|
|
|
|
|
14
|
|
|
use DERHANSEN\SfEventMgt\Utility\PageUtility; |
|
15
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
16
|
|
|
|
|
17
|
|
|
class CategoryDemand |
|
18
|
|
|
{ |
|
19
|
|
|
public const ORDER_FIELD_ALLOWED = ['title', 'uid', 'sorting']; |
|
20
|
|
|
|
|
21
|
|
|
protected string $storagePage = ''; |
|
22
|
|
|
protected bool $restrictToStoragePage = false; |
|
23
|
|
|
protected string $categories = ''; |
|
24
|
|
|
protected bool $includeSubcategories = false; |
|
25
|
|
|
protected string $orderField = 'uid'; |
|
26
|
|
|
protected string $orderDirection = 'asc'; |
|
27
|
|
|
|
|
28
|
|
|
public function setStoragePage(string $storagePage): void |
|
29
|
|
|
{ |
|
30
|
|
|
$this->storagePage = $storagePage; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function getStoragePage(): string |
|
34
|
|
|
{ |
|
35
|
|
|
return $this->storagePage; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function getRestrictToStoragePage(): bool |
|
39
|
|
|
{ |
|
40
|
|
|
return $this->restrictToStoragePage; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function setRestrictToStoragePage(bool $restrictToStoragePage): void |
|
44
|
|
|
{ |
|
45
|
|
|
$this->restrictToStoragePage = $restrictToStoragePage; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function getCategories(): string |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->categories; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function setCategories(string $categories): void |
|
54
|
|
|
{ |
|
55
|
|
|
$this->categories = $categories; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function getIncludeSubcategories(): bool |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->includeSubcategories; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function setIncludeSubcategories(bool $includeSubcategories): void |
|
64
|
|
|
{ |
|
65
|
|
|
$this->includeSubcategories = $includeSubcategories; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function getOrderDirection(): string |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->orderDirection; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function setOrderDirection(string $orderDirection): void |
|
74
|
|
|
{ |
|
75
|
|
|
$this->orderDirection = $orderDirection; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function getOrderField(): string |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->orderField; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function setOrderField(string $orderField): void |
|
84
|
|
|
{ |
|
85
|
|
|
$this->orderField = $orderField; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Creates a new CategoryDemand object from the given settings. Respects recursive setting for storage page |
|
90
|
|
|
* and extends all PIDs to children if set. |
|
91
|
|
|
* |
|
92
|
|
|
* @param array $settings |
|
93
|
|
|
* @return CategoryDemand |
|
94
|
|
|
*/ |
|
95
|
|
|
public static function createFromSettings(array $settings = []): self |
|
96
|
|
|
{ |
|
97
|
|
|
$demand = GeneralUtility::makeInstance(CategoryDemand::class); |
|
98
|
|
|
$demand->setStoragePage( |
|
99
|
|
|
PageUtility::extendPidListByChildren( |
|
100
|
|
|
(string)($settings['storagePage'] ?? ''), |
|
101
|
|
|
(int)($settings['recursive'] ?? 0) |
|
102
|
|
|
) |
|
103
|
|
|
); |
|
104
|
|
|
$demand->setRestrictToStoragePage((bool)($settings['restrictForeignRecordsToStoragePage'] ?? false)); |
|
105
|
|
|
$demand->setCategories($settings['categoryMenu']['categories'] ?? ''); |
|
106
|
|
|
$demand->setIncludeSubcategories((bool)($settings['categoryMenu']['includeSubcategories'] ?? false)); |
|
107
|
|
|
$demand->setOrderField($settings['categoryMenu']['orderField'] ?? 'uid'); |
|
108
|
|
|
$demand->setOrderDirection($settings['categoryMenu']['orderDirection'] ?? 'asc'); |
|
109
|
|
|
return $demand; |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|