Subida del módulo y tema de PrestaShop

This commit is contained in:
Kaloyan
2026-04-09 18:31:51 +02:00
parent 12c253296f
commit 16b3ff9424
39262 changed files with 7418797 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Extension\HtmlSanitizer;
use Psr\Container\ContainerInterface;
use Symfony\Component\Form\AbstractExtension;
/**
* Integrates the HtmlSanitizer component with the Form library.
*
* @author Nicolas Grekas <p@tchwork.com>
*/
class HtmlSanitizerExtension extends AbstractExtension
{
public function __construct(
private ContainerInterface $sanitizers,
private string $defaultSanitizer = 'default',
) {
}
protected function loadTypeExtensions(): array
{
return [
new Type\TextTypeHtmlSanitizerExtension($this->sanitizers, $this->defaultSanitizer),
];
}
}

View File

@@ -0,0 +1,72 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Form\Extension\HtmlSanitizer\Type;
use Psr\Container\ContainerInterface;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class TextTypeHtmlSanitizerExtension extends AbstractTypeExtension
{
public function __construct(
private ContainerInterface $sanitizers,
private string $defaultSanitizer = 'default',
) {
}
public static function getExtendedTypes(): iterable
{
return [TextType::class];
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefaults(['sanitize_html' => false, 'sanitizer' => null])
->setAllowedTypes('sanitize_html', 'bool')
->setAllowedTypes('sanitizer', ['string', 'null'])
;
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
if (!$options['sanitize_html']) {
return;
}
$sanitizers = $this->sanitizers;
$sanitizer = $options['sanitizer'] ?? $this->defaultSanitizer;
$builder->addEventListener(
FormEvents::PRE_SUBMIT,
static function (FormEvent $event) use ($sanitizers, $sanitizer) {
if (\is_scalar($data = $event->getData()) && '' !== trim($data)) {
$event->setData($sanitizers->get($sanitizer)->sanitize($data));
}
},
10000 /* as soon as possible */
);
}
}