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]>
42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace EP\EpTheme\ViewHelpers\Stimulus;
|
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
|
|
|
/**
|
|
* This code is adapted from the Symfony WebpackEncoreBundle package.
|
|
* (c) Fabien Potencier <[email protected]>
|
|
*/
|
|
class AbstractStimulusViewHelper extends AbstractViewHelper
|
|
{
|
|
/**
|
|
* This method is taken from symfony/webpack-encore-bundle
|
|
*
|
|
* Normalize a Stimulus controller name into its HTML equivalent (no special character and / becomes --).
|
|
*
|
|
* @see https://stimulus.hotwire.dev/reference/controllers
|
|
*/
|
|
protected static function normalizeControllerName(string $str): string
|
|
{
|
|
return preg_replace('/^@/', '', str_replace('_', '-', str_replace('/', '--', $str)));
|
|
}
|
|
|
|
/**
|
|
* This method is taken from symfony/webpack-encore-bundle
|
|
*
|
|
* Normalize a Stimulus Value API key into its HTML equivalent ("kebab case").
|
|
* Backport features from symfony/string.
|
|
*
|
|
* @see https://stimulus.hotwire.dev/reference/values
|
|
*/
|
|
protected static function normalizeKeyName(string $str): string
|
|
{
|
|
// Adapted from ByteString::camel
|
|
$str = ucfirst(str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $str))));
|
|
|
|
// Adapted from ByteString::snake
|
|
return strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1-\2', $str));
|
|
}
|
|
}
|