rector.php gets the PHP sets up to 8.5. Mostly constructor promotion with readonly properties, typed class constants, ??=, arrow functions, str_contains/str_starts_with, catch without unused variables, array_any and #[\Override] on overridden properties; array_key_exists() keys are cast to string (null keys are deprecated in PHP 8.5). Long promoted constructor signatures are wrapped one parameter per line. Checked locally: a crawl of ~1,900 frontend URLs over all sites and the backchannel APIs (/api/hotel, /api/product, content feed manifest and records of every type) render the same as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
77 lines
2.5 KiB
PHP
77 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace EP\EpTheme\ViewHelpers;
|
|
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
|
|
|
class ContainerViewHelper extends AbstractViewHelper
|
|
{
|
|
/**
|
|
* @var int[]
|
|
*/
|
|
protected static $scale = [
|
|
'default' => 0,
|
|
'small' => 8,
|
|
'large' => 16,
|
|
];
|
|
|
|
/**
|
|
* @var bool
|
|
*/
|
|
#[\Override]
|
|
protected $escapeOutput = false;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected static $columnsWithoutContainers = [ 0, 1, 3 ];
|
|
|
|
public function initializeArguments()
|
|
{
|
|
parent::initializeArguments();
|
|
|
|
$this->registerArgument('content', 'string', 'The content');
|
|
$this->registerArgument('cssClasses', 'string', 'Additional CSS classes');
|
|
$this->registerArgument('rteContent', 'boolean', 'Is RTE content', false, false);
|
|
$this->registerArgument('data', 'Array', 'The record data', true);
|
|
}
|
|
|
|
/**
|
|
* @param array $arguments
|
|
* @param \Closure $renderChildrenClosure
|
|
* @param RenderingContextInterface $renderingContext
|
|
* @return mixed
|
|
*/
|
|
public function render()
|
|
{
|
|
$content = $this->renderChildren();
|
|
$content ??= $this->arguments['content'];
|
|
$classes = [];
|
|
if (\in_array($this->arguments['data']['colPos'] ?? null, static::$columnsWithoutContainers, false)) {
|
|
$classes[] = 'container';
|
|
}
|
|
if ($this->arguments['cssClasses'] !== null) {
|
|
$classes[] = $this->arguments['cssClasses'];
|
|
}
|
|
if (!empty($this->arguments['data']['space_before_class'])) {
|
|
$scaleTop = static::$scale[$this->arguments['data']['space_before_class']];
|
|
$classes[] = sprintf('pt-%d', $scaleTop);
|
|
}
|
|
if (!empty($this->arguments['data']['space_after_class'])) {
|
|
$scaleBottom = static::$scale[$this->arguments['data']['space_after_class']];
|
|
$classes[] = sprintf('pb-%d', $scaleBottom);
|
|
}
|
|
if ('default' !== ($this->arguments['data']['frame_class'] ?? null)) {
|
|
$classes[] = $this->arguments['data']['frame_class'] ?? null;
|
|
}
|
|
if (count($classes) > 0) {
|
|
return sprintf('<div class="%s"%s>%s</div>', implode(' ', $classes), $this->arguments['rteContent'] ? ' data-rte-content' : '', $content);
|
|
}
|
|
if ($this->arguments['rteContent']) {
|
|
return sprintf('<div data-rte-content>%s</div>', $content);
|
|
}
|
|
return $content;
|
|
}
|
|
}
|