Files
typo3-13/packages/ep_theme/Classes/ViewHelpers/PriceViewHelper.php
T
frommeandClaude Opus 5.5 f4556ee75c refactor: remove dead code via Rector
rector.php gets the deadCode set: @param/@return/@var tags that only
repeat native types, === true comparisons, three unused constructor
dependencies (DateService, ProductDataService, AjaxWatchlistController),
the unused reseller lookup in ContextProcessor and an always-false check
in AbstractMappedFinisher (trimExplode with removeEmpty never yields an
empty remote name).

Checked locally: frontend crawl (~1,900 URLs) and the backchannel APIs
render the same as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 11:10:20 +01:00

43 lines
1.2 KiB
PHP

<?php
namespace EP\EpTheme\ViewHelpers;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic;
/**
* Formats a euro amount the way the website always has for whole euros ("229",
* "1234"), and with German decimals where there are cents ("99,90"). Prices are
* stored with cents, and the database hands them over as strings like "229.00".
*
* Keep in sync with formatPrice() in pricetable_controller.js.
*
* Usage: {row.minPrice -> ep:price()} €
*/
class PriceViewHelper extends AbstractViewHelper
{
use CompileWithContentArgumentAndRenderStatic;
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('value', 'mixed', 'Amount in euros');
}
/**
* @return string
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
$amount = round((float) $renderChildrenClosure(), 2);
$decimals = floor($amount) === $amount ? 0 : 2;
return number_format($amount, $decimals, ',', '');
}
}