|
1
|
|
|
<?php |
|
2
|
|
|
namespace Qbus\Qbtools\Hooks; |
|
3
|
|
|
|
|
4
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
5
|
|
|
use TYPO3\CMS\Core\Service\FlexFormService; |
|
6
|
|
|
use TYPO3\CMS\Core\Utility\ArrayUtility; |
|
7
|
|
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectGetDataHookInterface; |
|
8
|
|
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; |
|
9
|
|
|
|
|
10
|
|
|
class ContentObjectGetDataHook implements ContentObjectGetDataHookInterface |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* Extends the getData()-Method of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer to process more/other commands |
|
14
|
|
|
* |
|
15
|
|
|
* @param string $getDataString Full content of getData-request e.g. "TSFE:id // field:title // field:uid |
|
16
|
|
|
* @param array $fields Current field-array |
|
17
|
|
|
* @param string $sectionValue Currently examined section value of the getData request e.g. "field:title |
|
18
|
|
|
* @param string $returnValue Current returnValue that was processed so far by getData |
|
19
|
|
|
* @param ContentObjectRenderer $parentObject Parent content object |
|
20
|
|
|
* @return string Get data result |
|
21
|
|
|
*/ |
|
22
|
|
|
public function getDataExtension( |
|
23
|
|
|
$getDataString, |
|
24
|
|
|
array $fields, |
|
25
|
|
|
$sectionValue, |
|
26
|
|
|
$returnValue, |
|
27
|
|
|
ContentObjectRenderer &$parentObject |
|
28
|
|
|
) { |
|
29
|
|
|
$parts = explode(':', $sectionValue, 2); |
|
30
|
|
|
$type = strtolower(trim($parts[0])); |
|
31
|
|
|
$key = trim($parts[1]); |
|
32
|
|
|
|
|
33
|
|
|
switch ($type) { |
|
34
|
|
|
case 'qbtools_flexform_field': |
|
35
|
|
|
// Fallback to Extbase FlexFormService for TYPo3 v8 |
|
36
|
|
|
$flexFormServiceClassName = class_exists(FlexFormService::class) ? FlexFormService::class : 'TYPO3\\CMS\\Extbase\\Service\\FlexFormService'; |
|
37
|
|
|
$flexform_service = GeneralUtility::makeInstance($flexFormServiceClassName); |
|
38
|
|
|
$flexform_fields = $flexform_service->convertFlexFormContentToArray($fields['pi_flexform']); |
|
39
|
|
|
$returnValue = ArrayUtility::getValueByPath($flexform_fields, $key, '.'); |
|
40
|
|
|
break; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return $returnValue; |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|