Я впервые использую гибкий контейнер в своем расширении. В целом он работает очень хорошо, за одним исключением. Вместо подсчета числа я получаю случайную последовательность чисел в выводе массива:
Вывод:
test => array(3 items)
5eed21aab6294871086793 => array(1 item)
container => array(1 item)
5eed21b04dbeb100785974 => array(1 item)
container => array(1 item)
5eede5ce2b61c012766257 => array(1 item)
container => array(1 item)
Должно быть:
test => array(3 items)
1 => array(1 item)
container => array(1 item)
2 => array(1 item)
container => array(1 item)
3 => array(1 item)
container => array(1 item)
My Setup
TS:
tt_content.blockquote >
tt_content.blockquote =< lib.contentElement
tt_content.blockquote {
templateName = Mytemplate
dataProcessing.10 = MY\myext\DataProcessing\FlexFormProcessor
dataProcessing.10 {
if.isTrue.field = pi_flexform
fieldName = pi_flexform
as = settings
}
templateRootPaths {
20 = EXT:myext/Resources/Private/Templates/
}
Процессор Flexform
?php
namespace MY\Myext\DataProcessing;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
class FlexFormProcessor implements DataProcessorInterface
{
/**
* Process flexform field data to an array
*
* @param ContentObjectRenderer $cObj The data of the content element or page
* @param array $contentObjectConfiguration The configuration of Content Object
* @param array $processorConfiguration The configuration of this processor
* @param array $processedData Key/value store of processed data (e.g. to be passed to a Fluid View)
*
* @return array the processed data as key/value store
*/
public function process(
ContentObjectRenderer $cObj,
array $contentObjectConfiguration,
array $processorConfiguration,
array $processedData
)
{
if (isset($processorConfiguration['if.']) && !$cObj->checkIf($processorConfiguration['if.'])) {
return $processedData;
}
// set targetvariable, default "flexform"
$targetVariableName = $cObj->stdWrapValue('as', $processorConfiguration, 'flexform');
// set fieldname, default "pi_flexform"
$fieldName = $cObj->stdWrapValue('fieldName', $processorConfiguration, 'pi_flexform');
// parse flexform
$flexformService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Service\\FlexFormService');
$processedData[$targetVariableName] = $flexformService->convertFlexFormContentToArray($cObj->data[$fieldName]);
// if targetvariable is settings, try to merge it with contentObjectConfiguration['settings.']
if ($targetVariableName == 'settings') {
if (is_array($contentObjectConfiguration['settings.'])) {
$convertedConf = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($contentObjectConfiguration['settings.']);
foreach ($convertedConf as $key => $value) {
if (!isset($processedData[$targetVariableName][$key])
|| $processedData[$targetVariableName][$key] == false) {
$processedData[$targetVariableName][$key] = $value;
}
}
}
}
return $processedData;
}
}
Flexform:
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<ROOT>
<type>array</type>
<el>
<test>
<section>1</section>
<type>array</type>
<title>Contact form recipients</title>
<el>
<container>
<title>Recipient</title>
<type>array</type>
<el>
<email>
<TCEforms>
<label>Email</label>
<config>
<type>input</type>
<size>48</size>
</config>
</TCEforms>
</email>
</el>
</container>
</el>
</test>
</el>
</ROOT>
</T3DataStructure>
Есть ли какое-либо решение, чтобы изменить это? Заранее спасибо!