chore: copy ep_products and ep_theme from EP/website@9593cc8
Copied unchanged from public/typo3conf/ext/ of EP/website at 9593cc8631354f8a363d6609de8b7433f669a9a0 (Git-tracked files only). History stays in the old repository. Only composer.json files are added so the extensions install as path packages. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
59afaecea1
commit
a46918de9d
778 files changed
+67000
-2
No files matched your search
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\ViewHelpers\Stimulus;
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* This code is adapted from the Symfony WebpackEncoreBundle package.
|
||||
* (c) Fabien Potencier <[email protected]>
|
||||
*/
|
||||
class ControllerViewHelper extends AbstractStimulusViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
protected $escapeOutput = false;
|
||||
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
|
||||
$this->registerArgument('controller', 'mixed', 'Controller name(s)', true);
|
||||
$this->registerArgument('values', 'array', 'Controller values', false, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(
|
||||
array $arguments,
|
||||
\Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
)
|
||||
{
|
||||
$dataOrControllerName = $arguments['controller'];
|
||||
$controllerValues = $arguments['values'];
|
||||
|
||||
if (\is_string($dataOrControllerName)) {
|
||||
$data = [$dataOrControllerName => $controllerValues];
|
||||
} else {
|
||||
if ($controllerValues) {
|
||||
throw new \InvalidArgumentException('You cannot pass an array to the first and second argument of stimulus_controller(): check the documentation.');
|
||||
}
|
||||
|
||||
$data = $dataOrControllerName;
|
||||
|
||||
if (!$data) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
$controllers = [];
|
||||
$values = [];
|
||||
|
||||
foreach ($data as $controllerName => $controllerValues) {
|
||||
$controllerName = static::normalizeControllerName($controllerName);
|
||||
$controllers[] = $controllerName;
|
||||
|
||||
foreach ($controllerValues as $key => $value) {
|
||||
if (!is_scalar($value)) {
|
||||
$value = json_encode($value);
|
||||
}
|
||||
|
||||
if (\is_bool($value)) {
|
||||
$value = $value ? 'true' : 'false';
|
||||
}
|
||||
|
||||
$key = static::normalizeKeyName($key);
|
||||
$value = htmlspecialchars($value, ENT_QUOTES);
|
||||
|
||||
$values[] = 'data-'.$controllerName.'-'.$key.'-value="'.$value.'"';
|
||||
}
|
||||
}
|
||||
|
||||
return rtrim('data-controller="'.implode(' ', $controllers).'" '.implode(' ', $values));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user