Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
@@ -15,6 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\HttpKernel\Kernel;
/**
* CocurSlugifyExtension
@@ -38,8 +39,12 @@ class CocurSlugifyExtension extends Extension
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
if (empty($config['rulesets'])) {
unset($config['rulesets']);
}
// Extract slugify arguments from config
$slugifyArguments = array_intersect_key($config, array_flip(['lowercase', 'separator', 'regexp', 'rulesets']));
$slugifyArguments = array_intersect_key($config, array_flip(['lowercase', 'trim', 'strip_tags', 'separator', 'regexp', 'rulesets']));
$container->setDefinition('cocur_slugify', new Definition('Cocur\Slugify\Slugify', [$slugifyArguments]));
$container
@@ -53,5 +58,10 @@ class CocurSlugifyExtension extends Extension
->addTag('twig.extension')
->setPublic(false);
$container->setAlias('slugify', 'cocur_slugify');
// for symfony versions >= 3.3
if (Kernel::VERSION_ID >= 30300) {
$container->setAlias('Cocur\Slugify\SlugifyInterface', 'cocur_slugify');
}
}
}
+14 -4
View File
@@ -21,13 +21,23 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('cocur_slugify');
$treeBuilder = new TreeBuilder('cocur_slugify');
// Keep compatibility with symfony/config < 4.2
if (\method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
$rootNode = $treeBuilder->root('cocur_slugify');
}
$rootNode
->children()
->booleanNode('lowercase')->defaultTrue()->end()
->scalarNode('separator')->defaultValue('-')->end()
->booleanNode('lowercase')->end()
->booleanNode('lowercase_after_regexp')->end()
->booleanNode('trim')->end()
->booleanNode('strip_tags')->end()
->scalarNode('separator')->end()
->scalarNode('regexp')->end()
->arrayNode('rulesets')->prototype('scalar')->end()
->end();
@@ -66,4 +66,15 @@ class SlugifyExtension extends \Twig_Extension
{
return $this->slugify->slugify($string, $separator);
}
/**
* get Name
*
* @return string
*/
public function getName()
{
return "SlugifyExtension";
}
}
File diff suppressed because it is too large Load Diff
+17 -3
View File
@@ -26,7 +26,7 @@ use Cocur\Slugify\RuleProvider\RuleProviderInterface;
*/
class Slugify implements SlugifyInterface
{
const LOWERCASE_NUMBERS_DASHES = '/([^A-Za-z0-9]|-)+/';
const LOWERCASE_NUMBERS_DASHES = '/[^A-Za-z0-9]+/';
/**
* @var array<string,string>
@@ -45,11 +45,15 @@ class Slugify implements SlugifyInterface
'regexp' => self::LOWERCASE_NUMBERS_DASHES,
'separator' => '-',
'lowercase' => true,
'lowercase_after_regexp' => false,
'trim' => true,
'strip_tags' => false,
'rulesets' => [
'default',
// Languages are preferred if they appear later, list is ordered by number of
// websites in that language
// https://en.wikipedia.org/wiki/Languages_used_on_the_Internet#Content_languages_for_websites
'armenian',
'azerbaijani',
'burmese',
'hindi',
@@ -110,16 +114,26 @@ class Slugify implements SlugifyInterface
$rules = $this->rules;
}
$string = ($options['strip_tags'])
? strip_tags($string)
: $string;
$string = strtr($string, $rules);
unset($rules);
if ($options['lowercase']) {
if ($options['lowercase'] && !$options['lowercase_after_regexp']) {
$string = mb_strtolower($string);
}
$string = preg_replace($options['regexp'], $options['separator'], $string);
return trim($string, $options['separator']);
if ($options['lowercase'] && $options['lowercase_after_regexp']) {
$string = mb_strtolower($string);
}
return ($options['trim'])
? trim($string, $options['separator'])
: $string;
}
/**