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]>
53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace EP\EpTheme\ViewHelpers;
|
|
|
|
use EP\EpProducts\Domain\Model\Hotel;
|
|
use EP\EpProducts\Domain\Model\Region;
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
|
|
|
class GmapsUrlViewHelper extends AbstractViewHelper
|
|
{
|
|
/**
|
|
* @var bool
|
|
*/
|
|
#[\Override]
|
|
protected $escapeOutput = false;
|
|
|
|
const URLBASE = 'http://maps.google.com/maps?q=%s,%s&t=%s&z=%d';
|
|
|
|
public function initializeArguments()
|
|
{
|
|
parent::initializeArguments();
|
|
|
|
$this->registerArgument('hotel', Hotel::class, 'The hotel');
|
|
$this->registerArgument('region', Region::class, 'The region');
|
|
$this->registerArgument('type', 'string', 'The map type', false, 'p');
|
|
$this->registerArgument('zoom', 'int', 'The zoom level', false, 10);
|
|
}
|
|
|
|
/**
|
|
* @param array $arguments
|
|
* @param \Closure $renderChildrenClosure
|
|
* @param RenderingContextInterface $renderingContext
|
|
* @return mixed
|
|
*/
|
|
public function render()
|
|
{
|
|
$hotel = $this->arguments['hotel'];
|
|
$region = $this->arguments['region'];
|
|
if ($hotel !== null && $hotel->getLatitude() && $hotel->getLongitude()) {
|
|
$source = $hotel;
|
|
} elseif ($hotel !== null && $hotel->getRegion()->getLatitude() && $hotel->getRegion()->getLongitude()) {
|
|
$source = $hotel->getRegion();
|
|
} elseif ($region !== null) {
|
|
$source = $region;
|
|
} else {
|
|
return 'http://www.google.de/maps';
|
|
}
|
|
return sprintf(static::URLBASE, $source->getLatitude(), $source->getLongitude(), $this->arguments['type'], $this->arguments['zoom']);
|
|
}
|
|
|
|
}
|