initializeResultArray(); if (!isset($this->data['renderData']['fieldControl'])) { return $result; } $languageService = $this->getLanguageService(); $fieldControl = $this->data['renderData']['fieldControl']; $orderedFieldControl = $this->dependencyOrderingService->orderByDependencies($fieldControl); foreach ($orderedFieldControl as $anOrderedFieldControl => $orderedFieldControlConfiguration) { if (isset($orderedFieldControlConfiguration['disabled']) && $orderedFieldControlConfiguration['disabled'] || !isset($fieldControl[$anOrderedFieldControl]['renderType']) ) { // Don't consider this control if disabled. // Also ignore if renderType is not given. // Missing renderType may happen if an element registers a default field control // as disabled, and TCA enabled that. If then additionally for instance the // element renderType is changed to an element that doesn't register the control // by default anymore, this would then fatal if we don't continue here. // @todo: the above scenario indicates a small configuration flaw, maybe log an error somewhere? continue; } $options = $this->data; $options['renderType'] = $fieldControl[$anOrderedFieldControl]['renderType']; $options['renderData']['fieldControlOptions'] = $orderedFieldControlConfiguration['options'] ?? []; $controlResult = $this->nodeFactory->create($options)->render(); // If the controlResult is empty (this control rendered nothing), continue to next one if (empty($controlResult)) { continue; } if (empty($controlResult['iconIdentifier'])) { throw new \RuntimeException( 'Field controls must return an iconIdentifier', 1483890332 ); } if (empty($controlResult['title'])) { throw new \RuntimeException( 'Field controls must return a title', 1483890482 ); } if (empty($controlResult['linkAttributes'])) { throw new \RuntimeException( 'Field controls must return link attributes', 1483891272 ); } $icon = $controlResult['iconIdentifier']; $title = $languageService->sL($controlResult['title']); $linkAttributes = $controlResult['linkAttributes']; if (!isset($linkAttributes['class'])) { $linkAttributes['class'] = 'btn btn-default'; } else { $linkAttributes['class'] .= ' btn btn-default'; } if (!isset($linkAttributes['href'])) { $linkAttributes['href'] = '#'; } unset($controlResult['iconIdentifier']); unset($controlResult['title']); unset($controlResult['linkAttributes']); $html = []; $html[] = ''; $html[] = $this->iconFactory->getIcon($icon, IconSize::SMALL)->setTitle($title)->render(); $html[] = ''; $finalControlResult = $this->initializeResultArray(); $finalControlResult = array_merge($finalControlResult, $controlResult); $finalControlResult['html'] = implode(LF, $html); $result = $this->mergeChildReturnIntoExistingResult($result, $finalControlResult); } return $result; } protected function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } }