@@ -16,145 +16,145 @@ |
||
16 | 16 | */ |
17 | 17 | class Selection extends AbstractEntity |
18 | 18 | { |
19 | - public const VISIBILITY_EVERYONE = 0; |
|
20 | - public const VISIBILITY_PRIVATE = 1; |
|
21 | - public const VISIBILITY_ADMIN_ONLY = 2; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var int |
|
25 | - */ |
|
26 | - protected $visibility; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - protected $name; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - protected $dataType; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - protected $query; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var string |
|
45 | - */ |
|
46 | - protected $speakingQuery; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var int |
|
50 | - */ |
|
51 | - protected $owner; |
|
52 | - |
|
53 | - /** |
|
54 | - * @param string $dataType |
|
55 | - * @return $this |
|
56 | - */ |
|
57 | - public function setDataType($dataType) |
|
58 | - { |
|
59 | - $this->dataType = $dataType; |
|
60 | - return $this; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function getDataType() |
|
67 | - { |
|
68 | - return $this->dataType; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @param string $query |
|
73 | - * @return $this |
|
74 | - */ |
|
75 | - public function setQuery($query) |
|
76 | - { |
|
77 | - $this->query = $query; |
|
78 | - return $this; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function getQuery() |
|
85 | - { |
|
86 | - return $this->query; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public function getSpeakingQuery() |
|
93 | - { |
|
94 | - return $this->speakingQuery; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @param string $speakingQuery |
|
99 | - * @return $this |
|
100 | - */ |
|
101 | - public function setSpeakingQuery($speakingQuery) |
|
102 | - { |
|
103 | - $this->speakingQuery = $speakingQuery; |
|
104 | - return $this; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @param string $name |
|
109 | - * @return $this |
|
110 | - */ |
|
111 | - public function setName($name) |
|
112 | - { |
|
113 | - $this->name = $name; |
|
114 | - return $this; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @return string |
|
119 | - */ |
|
120 | - public function getName() |
|
121 | - { |
|
122 | - return $this->name; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * @param int $visibility |
|
127 | - * @return $this |
|
128 | - */ |
|
129 | - public function setVisibility($visibility) |
|
130 | - { |
|
131 | - $this->visibility = $visibility; |
|
132 | - return $this; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @return int |
|
137 | - */ |
|
138 | - public function getVisibility() |
|
139 | - { |
|
140 | - return $this->visibility; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * @return int |
|
145 | - */ |
|
146 | - public function getOwner() |
|
147 | - { |
|
148 | - return $this->owner; |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * @param int $owner |
|
153 | - * @return $this |
|
154 | - */ |
|
155 | - public function setOwner($owner) |
|
156 | - { |
|
157 | - $this->owner = $owner; |
|
158 | - return $this; |
|
159 | - } |
|
19 | + public const VISIBILITY_EVERYONE = 0; |
|
20 | + public const VISIBILITY_PRIVATE = 1; |
|
21 | + public const VISIBILITY_ADMIN_ONLY = 2; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var int |
|
25 | + */ |
|
26 | + protected $visibility; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + protected $name; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + protected $dataType; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + protected $query; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var string |
|
45 | + */ |
|
46 | + protected $speakingQuery; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var int |
|
50 | + */ |
|
51 | + protected $owner; |
|
52 | + |
|
53 | + /** |
|
54 | + * @param string $dataType |
|
55 | + * @return $this |
|
56 | + */ |
|
57 | + public function setDataType($dataType) |
|
58 | + { |
|
59 | + $this->dataType = $dataType; |
|
60 | + return $this; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function getDataType() |
|
67 | + { |
|
68 | + return $this->dataType; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @param string $query |
|
73 | + * @return $this |
|
74 | + */ |
|
75 | + public function setQuery($query) |
|
76 | + { |
|
77 | + $this->query = $query; |
|
78 | + return $this; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function getQuery() |
|
85 | + { |
|
86 | + return $this->query; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public function getSpeakingQuery() |
|
93 | + { |
|
94 | + return $this->speakingQuery; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @param string $speakingQuery |
|
99 | + * @return $this |
|
100 | + */ |
|
101 | + public function setSpeakingQuery($speakingQuery) |
|
102 | + { |
|
103 | + $this->speakingQuery = $speakingQuery; |
|
104 | + return $this; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @param string $name |
|
109 | + * @return $this |
|
110 | + */ |
|
111 | + public function setName($name) |
|
112 | + { |
|
113 | + $this->name = $name; |
|
114 | + return $this; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @return string |
|
119 | + */ |
|
120 | + public function getName() |
|
121 | + { |
|
122 | + return $this->name; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * @param int $visibility |
|
127 | + * @return $this |
|
128 | + */ |
|
129 | + public function setVisibility($visibility) |
|
130 | + { |
|
131 | + $this->visibility = $visibility; |
|
132 | + return $this; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * @return int |
|
137 | + */ |
|
138 | + public function getVisibility() |
|
139 | + { |
|
140 | + return $this->visibility; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * @return int |
|
145 | + */ |
|
146 | + public function getOwner() |
|
147 | + { |
|
148 | + return $this->owner; |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * @param int $owner |
|
153 | + * @return $this |
|
154 | + */ |
|
155 | + public function setOwner($owner) |
|
156 | + { |
|
157 | + $this->owner = $owner; |
|
158 | + return $this; |
|
159 | + } |
|
160 | 160 | } |
@@ -16,25 +16,25 @@ |
||
16 | 16 | */ |
17 | 17 | class LanguageValidator |
18 | 18 | { |
19 | - /** |
|
20 | - * Check whether the $language is valid. |
|
21 | - * |
|
22 | - * @param int $language |
|
23 | - * @throws \Exception |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function validate($language) |
|
27 | - { |
|
28 | - if (!$this->getLanguageService()->languageExists((int)$language)) { |
|
29 | - throw new \Exception('The language "' . $language . '" does not exist', 1351605542); |
|
30 | - } |
|
31 | - } |
|
19 | + /** |
|
20 | + * Check whether the $language is valid. |
|
21 | + * |
|
22 | + * @param int $language |
|
23 | + * @throws \Exception |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function validate($language) |
|
27 | + { |
|
28 | + if (!$this->getLanguageService()->languageExists((int)$language)) { |
|
29 | + throw new \Exception('The language "' . $language . '" does not exist', 1351605542); |
|
30 | + } |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * @return LanguageService|object |
|
35 | - */ |
|
36 | - protected function getLanguageService() |
|
37 | - { |
|
38 | - return GeneralUtility::makeInstance(LanguageService::class); |
|
39 | - } |
|
33 | + /** |
|
34 | + * @return LanguageService|object |
|
35 | + */ |
|
36 | + protected function getLanguageService() |
|
37 | + { |
|
38 | + return GeneralUtility::makeInstance(LanguageService::class); |
|
39 | + } |
|
40 | 40 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | public function validate($language) |
27 | 27 | { |
28 | 28 | if (!$this->getLanguageService()->languageExists((int)$language)) { |
29 | - throw new \Exception('The language "' . $language . '" does not exist', 1351605542); |
|
29 | + throw new \Exception('The language "'.$language.'" does not exist', 1351605542); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 |
@@ -17,19 +17,19 @@ |
||
17 | 17 | */ |
18 | 18 | class MatchesValidator extends AbstractValidator |
19 | 19 | { |
20 | - /** |
|
21 | - * Check if $matches is valid. If it is not valid, throw an exception. |
|
22 | - * |
|
23 | - * @param mixed $matches |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function isValid($matches) |
|
27 | - { |
|
28 | - foreach ($matches as $fieldName => $value) { |
|
29 | - if (!Tca::table()->hasField($fieldName)) { |
|
30 | - $message = sprintf('Field "%s" is not allowed. Actually, it is not configured in the TCA.', $fieldName); |
|
31 | - $this->addError($message, 1380019718); |
|
32 | - } |
|
33 | - } |
|
34 | - } |
|
20 | + /** |
|
21 | + * Check if $matches is valid. If it is not valid, throw an exception. |
|
22 | + * |
|
23 | + * @param mixed $matches |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function isValid($matches) |
|
27 | + { |
|
28 | + foreach ($matches as $fieldName => $value) { |
|
29 | + if (!Tca::table()->hasField($fieldName)) { |
|
30 | + $message = sprintf('Field "%s" is not allowed. Actually, it is not configured in the TCA.', $fieldName); |
|
31 | + $this->addError($message, 1380019718); |
|
32 | + } |
|
33 | + } |
|
34 | + } |
|
35 | 35 | } |
@@ -17,17 +17,17 @@ |
||
17 | 17 | */ |
18 | 18 | class FacetValidator extends AbstractValidator |
19 | 19 | { |
20 | - /** |
|
21 | - * Check if $facet is valid. If it is not valid, throw an exception. |
|
22 | - * |
|
23 | - * @param mixed $facet |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function isValid($facet) |
|
27 | - { |
|
28 | - if (!Tca::grid()->hasFacet($facet)) { |
|
29 | - $message = sprintf('Facet "%s" is not allowed. Actually, it was not configured to be displayed in the grid.', $facet); |
|
30 | - $this->addError($message, 1380019719); |
|
31 | - } |
|
32 | - } |
|
20 | + /** |
|
21 | + * Check if $facet is valid. If it is not valid, throw an exception. |
|
22 | + * |
|
23 | + * @param mixed $facet |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function isValid($facet) |
|
27 | + { |
|
28 | + if (!Tca::grid()->hasFacet($facet)) { |
|
29 | + $message = sprintf('Facet "%s" is not allowed. Actually, it was not configured to be displayed in the grid.', $facet); |
|
30 | + $this->addError($message, 1380019719); |
|
31 | + } |
|
32 | + } |
|
33 | 33 | } |
@@ -17,19 +17,19 @@ |
||
17 | 17 | */ |
18 | 18 | class ColumnsValidator extends AbstractValidator |
19 | 19 | { |
20 | - /** |
|
21 | - * Check if $columns is valid. If it is not valid, throw an exception. |
|
22 | - * |
|
23 | - * @param mixed $columns |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function isValid($columns) |
|
27 | - { |
|
28 | - foreach ($columns as $columnName) { |
|
29 | - if (!Tca::grid()->hasField($columnName)) { |
|
30 | - $message = sprintf('Column "%s" is not allowed. Actually, it was not configured to be displayed in the grid.', $columnName); |
|
31 | - $this->addError($message, 1380019720); |
|
32 | - } |
|
33 | - } |
|
34 | - } |
|
20 | + /** |
|
21 | + * Check if $columns is valid. If it is not valid, throw an exception. |
|
22 | + * |
|
23 | + * @param mixed $columns |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function isValid($columns) |
|
27 | + { |
|
28 | + foreach ($columns as $columnName) { |
|
29 | + if (!Tca::grid()->hasField($columnName)) { |
|
30 | + $message = sprintf('Column "%s" is not allowed. Actually, it was not configured to be displayed in the grid.', $columnName); |
|
31 | + $this->addError($message, 1380019720); |
|
32 | + } |
|
33 | + } |
|
34 | + } |
|
35 | 35 | } |
@@ -17,18 +17,18 @@ |
||
17 | 17 | */ |
18 | 18 | class ContentValidator |
19 | 19 | { |
20 | - /** |
|
21 | - * Check whether $Content object is valid. |
|
22 | - * |
|
23 | - * @param Content $content |
|
24 | - * @throws \Exception |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function validate(Content $content) |
|
28 | - { |
|
29 | - // Security check. |
|
30 | - if ($content->getUid() <= 0) { |
|
31 | - throw new MissingIdentifierException('Missing identifier for Content Object', 1351605542); |
|
32 | - } |
|
33 | - } |
|
20 | + /** |
|
21 | + * Check whether $Content object is valid. |
|
22 | + * |
|
23 | + * @param Content $content |
|
24 | + * @throws \Exception |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function validate(Content $content) |
|
28 | + { |
|
29 | + // Security check. |
|
30 | + if ($content->getUid() <= 0) { |
|
31 | + throw new MissingIdentifierException('Missing identifier for Content Object', 1351605542); |
|
32 | + } |
|
33 | + } |
|
34 | 34 | } |
@@ -18,35 +18,35 @@ |
||
18 | 18 | */ |
19 | 19 | class ToolValidator extends AbstractValidator |
20 | 20 | { |
21 | - /** |
|
22 | - * Check whether $tool is valid. |
|
23 | - * |
|
24 | - * @param string $tool |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public function isValid($tool) |
|
28 | - { |
|
29 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
30 | - $isValid = ToolRegistry::getInstance()->isAllowed($dataType, $tool); |
|
21 | + /** |
|
22 | + * Check whether $tool is valid. |
|
23 | + * |
|
24 | + * @param string $tool |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public function isValid($tool) |
|
28 | + { |
|
29 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
30 | + $isValid = ToolRegistry::getInstance()->isAllowed($dataType, $tool); |
|
31 | 31 | |
32 | - if (!$isValid) { |
|
33 | - $message = sprintf('This Tool "%s" is not allowed for the current data type.', $tool); |
|
34 | - $this->addError($message, 1409041510); |
|
35 | - } |
|
32 | + if (!$isValid) { |
|
33 | + $message = sprintf('This Tool "%s" is not allowed for the current data type.', $tool); |
|
34 | + $this->addError($message, 1409041510); |
|
35 | + } |
|
36 | 36 | |
37 | - if (!class_exists($tool)) { |
|
38 | - $message = sprintf('I could not find class "%s"', $tool); |
|
39 | - $this->addError($message, 1409041511); |
|
40 | - } |
|
41 | - } |
|
37 | + if (!class_exists($tool)) { |
|
38 | + $message = sprintf('I could not find class "%s"', $tool); |
|
39 | + $this->addError($message, 1409041511); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Get the Vidi Module Loader. |
|
45 | - * |
|
46 | - * @return ModuleLoader|object |
|
47 | - */ |
|
48 | - protected function getModuleLoader() |
|
49 | - { |
|
50 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
51 | - } |
|
43 | + /** |
|
44 | + * Get the Vidi Module Loader. |
|
45 | + * |
|
46 | + * @return ModuleLoader|object |
|
47 | + */ |
|
48 | + protected function getModuleLoader() |
|
49 | + { |
|
50 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
51 | + } |
|
52 | 52 | } |
@@ -19,104 +19,104 @@ |
||
19 | 19 | */ |
20 | 20 | class FieldPathResolver implements SingletonInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * Remove the prefixing path from the file name. |
|
24 | - * |
|
25 | - * @param string $fieldNameAndPath |
|
26 | - * @param string $dataType |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function stripFieldPath($fieldNameAndPath, $dataType = '') |
|
30 | - { |
|
31 | - $dataType = $this->getContextualDataType($dataType); |
|
22 | + /** |
|
23 | + * Remove the prefixing path from the file name. |
|
24 | + * |
|
25 | + * @param string $fieldNameAndPath |
|
26 | + * @param string $dataType |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function stripFieldPath($fieldNameAndPath, $dataType = '') |
|
30 | + { |
|
31 | + $dataType = $this->getContextualDataType($dataType); |
|
32 | 32 | |
33 | - if ($this->containsPath($fieldNameAndPath, $dataType)) { |
|
34 | - // Corresponds to the field name of the foreign table. |
|
35 | - $fieldParts = GeneralUtility::trimExplode('.', $fieldNameAndPath); |
|
36 | - $fieldName = $fieldParts[1]; |
|
37 | - } else { |
|
38 | - $fieldName = $fieldNameAndPath; |
|
39 | - } |
|
40 | - return $fieldName; |
|
41 | - } |
|
33 | + if ($this->containsPath($fieldNameAndPath, $dataType)) { |
|
34 | + // Corresponds to the field name of the foreign table. |
|
35 | + $fieldParts = GeneralUtility::trimExplode('.', $fieldNameAndPath); |
|
36 | + $fieldName = $fieldParts[1]; |
|
37 | + } else { |
|
38 | + $fieldName = $fieldNameAndPath; |
|
39 | + } |
|
40 | + return $fieldName; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Remove the suffixing field name |
|
45 | - * |
|
46 | - * @param string $fieldNameAndPath |
|
47 | - * @param string $dataType |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function stripFieldName($fieldNameAndPath, $dataType = '') |
|
51 | - { |
|
52 | - $dataType = $this->getContextualDataType($dataType); |
|
43 | + /** |
|
44 | + * Remove the suffixing field name |
|
45 | + * |
|
46 | + * @param string $fieldNameAndPath |
|
47 | + * @param string $dataType |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function stripFieldName($fieldNameAndPath, $dataType = '') |
|
51 | + { |
|
52 | + $dataType = $this->getContextualDataType($dataType); |
|
53 | 53 | |
54 | - if ($this->containsPath($fieldNameAndPath, $dataType)) { |
|
55 | - // Corresponds to the field name of the foreign table. |
|
56 | - $fieldParts = GeneralUtility::trimExplode('.', $fieldNameAndPath); |
|
57 | - $fieldName = $fieldParts[0]; |
|
58 | - } else { |
|
59 | - $fieldName = $fieldNameAndPath; |
|
60 | - } |
|
61 | - return $fieldName; |
|
62 | - } |
|
54 | + if ($this->containsPath($fieldNameAndPath, $dataType)) { |
|
55 | + // Corresponds to the field name of the foreign table. |
|
56 | + $fieldParts = GeneralUtility::trimExplode('.', $fieldNameAndPath); |
|
57 | + $fieldName = $fieldParts[0]; |
|
58 | + } else { |
|
59 | + $fieldName = $fieldNameAndPath; |
|
60 | + } |
|
61 | + return $fieldName; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Returns the class names to be applied to a cell ("td"). |
|
66 | - * |
|
67 | - * @param string $fieldNameAndPath |
|
68 | - * @param string $dataType |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - public function getDataType($fieldNameAndPath, $dataType = '') |
|
72 | - { |
|
73 | - $dataType = $this->getContextualDataType($dataType); |
|
64 | + /** |
|
65 | + * Returns the class names to be applied to a cell ("td"). |
|
66 | + * |
|
67 | + * @param string $fieldNameAndPath |
|
68 | + * @param string $dataType |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + public function getDataType($fieldNameAndPath, $dataType = '') |
|
72 | + { |
|
73 | + $dataType = $this->getContextualDataType($dataType); |
|
74 | 74 | |
75 | - if ($this->containsPath($fieldNameAndPath, $dataType)) { |
|
76 | - // Compute the foreign data type. |
|
77 | - $fieldParts = GeneralUtility::trimExplode('.', $fieldNameAndPath); |
|
78 | - $fieldNameAndPath = $fieldParts[0]; |
|
79 | - $dataType = Tca::table($dataType)->field($fieldNameAndPath)->getForeignTable(); |
|
80 | - } |
|
81 | - return $dataType; |
|
82 | - } |
|
75 | + if ($this->containsPath($fieldNameAndPath, $dataType)) { |
|
76 | + // Compute the foreign data type. |
|
77 | + $fieldParts = GeneralUtility::trimExplode('.', $fieldNameAndPath); |
|
78 | + $fieldNameAndPath = $fieldParts[0]; |
|
79 | + $dataType = Tca::table($dataType)->field($fieldNameAndPath)->getForeignTable(); |
|
80 | + } |
|
81 | + return $dataType; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Return the data type according to the context. |
|
86 | - * |
|
87 | - * @param $dataType |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function getContextualDataType($dataType) |
|
91 | - { |
|
92 | - if (!$dataType) { |
|
93 | - $dataType = $this->getModuleLoader()->getDataType(); |
|
94 | - } |
|
95 | - return $dataType; |
|
96 | - } |
|
84 | + /** |
|
85 | + * Return the data type according to the context. |
|
86 | + * |
|
87 | + * @param $dataType |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function getContextualDataType($dataType) |
|
91 | + { |
|
92 | + if (!$dataType) { |
|
93 | + $dataType = $this->getModuleLoader()->getDataType(); |
|
94 | + } |
|
95 | + return $dataType; |
|
96 | + } |
|
97 | 97 | |
98 | - /** |
|
99 | - * Tell whether the field name contains a path, e.g. metadata.title |
|
100 | - * But resolves the case when the field is composite e.g "items.sys_file_metadata" and looks as field path but is not! |
|
101 | - * A composite field = a field for a MM relation of type "group" where the table name is appended. |
|
102 | - * |
|
103 | - * @param string $fieldNameAndPath |
|
104 | - * @param string $dataType |
|
105 | - * @return boolean |
|
106 | - */ |
|
107 | - public function containsPath($fieldNameAndPath, $dataType) |
|
108 | - { |
|
109 | - $doesContainPath = strpos($fieldNameAndPath, '.') > 0 && !Tca::table($dataType)->hasField($fieldNameAndPath); // -> will make sure it is not a composite field name. |
|
110 | - return $doesContainPath; |
|
111 | - } |
|
98 | + /** |
|
99 | + * Tell whether the field name contains a path, e.g. metadata.title |
|
100 | + * But resolves the case when the field is composite e.g "items.sys_file_metadata" and looks as field path but is not! |
|
101 | + * A composite field = a field for a MM relation of type "group" where the table name is appended. |
|
102 | + * |
|
103 | + * @param string $fieldNameAndPath |
|
104 | + * @param string $dataType |
|
105 | + * @return boolean |
|
106 | + */ |
|
107 | + public function containsPath($fieldNameAndPath, $dataType) |
|
108 | + { |
|
109 | + $doesContainPath = strpos($fieldNameAndPath, '.') > 0 && !Tca::table($dataType)->hasField($fieldNameAndPath); // -> will make sure it is not a composite field name. |
|
110 | + return $doesContainPath; |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * Get the Vidi Module Loader. |
|
115 | - * |
|
116 | - * @return ModuleLoader |
|
117 | - */ |
|
118 | - protected function getModuleLoader() |
|
119 | - { |
|
120 | - return GeneralUtility::makeInstance(ModuleLoader::class); |
|
121 | - } |
|
113 | + /** |
|
114 | + * Get the Vidi Module Loader. |
|
115 | + * |
|
116 | + * @return ModuleLoader |
|
117 | + */ |
|
118 | + protected function getModuleLoader() |
|
119 | + { |
|
120 | + return GeneralUtility::makeInstance(ModuleLoader::class); |
|
121 | + } |
|
122 | 122 | } |
@@ -19,84 +19,84 @@ |
||
19 | 19 | */ |
20 | 20 | class ContentObjectResolver implements SingletonInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * @param Content $object |
|
24 | - * @param string $fieldNameAndPath |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - public function getDataType(Content $object, $fieldNameAndPath) |
|
28 | - { |
|
29 | - // Important to notice the field name can contains a path, e.g. metadata.title and must be sanitized. |
|
30 | - $relationalFieldName = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath); // ex: metadata.title -> metadata |
|
22 | + /** |
|
23 | + * @param Content $object |
|
24 | + * @param string $fieldNameAndPath |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + public function getDataType(Content $object, $fieldNameAndPath) |
|
28 | + { |
|
29 | + // Important to notice the field name can contains a path, e.g. metadata.title and must be sanitized. |
|
30 | + $relationalFieldName = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath); // ex: metadata.title -> metadata |
|
31 | 31 | |
32 | - // Handle case when field name leads to a relation. |
|
33 | - if ($object[$relationalFieldName] instanceof Content) { |
|
34 | - $resolvedDataType = $object[$relationalFieldName]->getDataType(); |
|
35 | - } else { |
|
36 | - $resolvedDataType = $object->getDataType(); |
|
37 | - } |
|
32 | + // Handle case when field name leads to a relation. |
|
33 | + if ($object[$relationalFieldName] instanceof Content) { |
|
34 | + $resolvedDataType = $object[$relationalFieldName]->getDataType(); |
|
35 | + } else { |
|
36 | + $resolvedDataType = $object->getDataType(); |
|
37 | + } |
|
38 | 38 | |
39 | - return $resolvedDataType; |
|
40 | - } |
|
39 | + return $resolvedDataType; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Fetch the value of an object according to a field path. |
|
44 | - * The returned value can be a string, int or array of Content objects. |
|
45 | - * |
|
46 | - * @param Content $object |
|
47 | - * @param string $fieldNameAndPath |
|
48 | - * @param string $fieldName |
|
49 | - * @param int $language |
|
50 | - * @return mixed |
|
51 | - */ |
|
52 | - public function getValue(Content $object, $fieldNameAndPath, $fieldName, $language = 0) |
|
53 | - { |
|
54 | - $resolvedContentObject = $this->getObject($object, $fieldNameAndPath); |
|
55 | - $resolvedValue = $resolvedContentObject[$fieldName]; |
|
42 | + /** |
|
43 | + * Fetch the value of an object according to a field path. |
|
44 | + * The returned value can be a string, int or array of Content objects. |
|
45 | + * |
|
46 | + * @param Content $object |
|
47 | + * @param string $fieldNameAndPath |
|
48 | + * @param string $fieldName |
|
49 | + * @param int $language |
|
50 | + * @return mixed |
|
51 | + */ |
|
52 | + public function getValue(Content $object, $fieldNameAndPath, $fieldName, $language = 0) |
|
53 | + { |
|
54 | + $resolvedContentObject = $this->getObject($object, $fieldNameAndPath); |
|
55 | + $resolvedValue = $resolvedContentObject[$fieldName]; |
|
56 | 56 | |
57 | - if (is_scalar($resolvedValue) && $language > 0) { |
|
58 | - $resolvedValue = $this->getLanguageService()->getLocalizedFieldName($resolvedContentObject, $language, $fieldName); |
|
59 | - } |
|
57 | + if (is_scalar($resolvedValue) && $language > 0) { |
|
58 | + $resolvedValue = $this->getLanguageService()->getLocalizedFieldName($resolvedContentObject, $language, $fieldName); |
|
59 | + } |
|
60 | 60 | |
61 | - return $resolvedValue; |
|
62 | - } |
|
61 | + return $resolvedValue; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Fetch the value of an object according to a field name and path. |
|
66 | - * The returned value is a Content object. |
|
67 | - * |
|
68 | - * @param Content $object |
|
69 | - * @param string $fieldNameAndPath |
|
70 | - * @return Content |
|
71 | - */ |
|
72 | - public function getObject(Content $object, $fieldNameAndPath) |
|
73 | - { |
|
74 | - // Important to notice the field name can contains a path, e.g. metadata.title and must be sanitized. |
|
75 | - $fieldPath = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath); // ex: metadata.title -> metadata |
|
64 | + /** |
|
65 | + * Fetch the value of an object according to a field name and path. |
|
66 | + * The returned value is a Content object. |
|
67 | + * |
|
68 | + * @param Content $object |
|
69 | + * @param string $fieldNameAndPath |
|
70 | + * @return Content |
|
71 | + */ |
|
72 | + public function getObject(Content $object, $fieldNameAndPath) |
|
73 | + { |
|
74 | + // Important to notice the field name can contains a path, e.g. metadata.title and must be sanitized. |
|
75 | + $fieldPath = $this->getFieldPathResolver()->stripFieldName($fieldNameAndPath); // ex: metadata.title -> metadata |
|
76 | 76 | |
77 | - // Handle case when field name leads to a relation. |
|
78 | - if ($object[$fieldPath] instanceof Content) { |
|
79 | - $resolvedObject = $object[$fieldPath]; |
|
80 | - } else { |
|
81 | - $resolvedObject = $object; |
|
82 | - } |
|
77 | + // Handle case when field name leads to a relation. |
|
78 | + if ($object[$fieldPath] instanceof Content) { |
|
79 | + $resolvedObject = $object[$fieldPath]; |
|
80 | + } else { |
|
81 | + $resolvedObject = $object; |
|
82 | + } |
|
83 | 83 | |
84 | - return $resolvedObject; |
|
85 | - } |
|
84 | + return $resolvedObject; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @return FieldPathResolver|object |
|
89 | - */ |
|
90 | - protected function getFieldPathResolver() |
|
91 | - { |
|
92 | - return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
93 | - } |
|
87 | + /** |
|
88 | + * @return FieldPathResolver|object |
|
89 | + */ |
|
90 | + protected function getFieldPathResolver() |
|
91 | + { |
|
92 | + return GeneralUtility::makeInstance(FieldPathResolver::class); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * @return LanguageService|object |
|
97 | - */ |
|
98 | - protected function getLanguageService() |
|
99 | - { |
|
100 | - return GeneralUtility::makeInstance(LanguageService::class); |
|
101 | - } |
|
95 | + /** |
|
96 | + * @return LanguageService|object |
|
97 | + */ |
|
98 | + protected function getLanguageService() |
|
99 | + { |
|
100 | + return GeneralUtility::makeInstance(LanguageService::class); |
|
101 | + } |
|
102 | 102 | } |