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,33 @@
<?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\Bridge\ProxyManager\Internal;
use ProxyManager\Configuration;
/**
* @internal
*/
trait LazyLoadingFactoryTrait
{
private readonly ProxyGenerator $generator;
public function __construct(Configuration $config, ProxyGenerator $generator)
{
parent::__construct($config);
$this->generator = $generator;
}
public function getGenerator(): ProxyGenerator
{
return $this->generator;
}
}

View File

@@ -0,0 +1,86 @@
<?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\Bridge\ProxyManager\Internal;
use Laminas\Code\Generator\ClassGenerator;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator;
use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
use Symfony\Component\DependencyInjection\Definition;
/**
* @internal
*/
class ProxyGenerator implements ProxyGeneratorInterface
{
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator, array $proxyOptions = []): void
{
(new LazyLoadingValueHolderGenerator())->generate($originalClass, $classGenerator, $proxyOptions);
foreach ($classGenerator->getMethods() as $method) {
if (str_starts_with($originalClass->getFilename(), __FILE__)) {
$method->setBody(str_replace(var_export($originalClass->name, true), '__CLASS__', $method->getBody()));
}
}
if (str_starts_with($originalClass->getFilename(), __FILE__)) {
$interfaces = $classGenerator->getImplementedInterfaces();
array_pop($interfaces);
$classGenerator->setImplementedInterfaces(array_merge($interfaces, $originalClass->getInterfaceNames()));
}
}
public function getProxifiedClass(Definition $definition): ?string
{
if (!$definition->hasTag('proxy')) {
if (!($class = $definition->getClass()) || !(class_exists($class) || interface_exists($class, false))) {
return null;
}
return (new \ReflectionClass($class))->name;
}
if (!$definition->isLazy()) {
throw new \InvalidArgumentException(\sprintf('Invalid definition for service of class "%s": setting the "proxy" tag on a service requires it to be "lazy".', $definition->getClass()));
}
$tags = $definition->getTag('proxy');
if (!isset($tags[0]['interface'])) {
throw new \InvalidArgumentException(\sprintf('Invalid definition for service of class "%s": the "interface" attribute is missing on the "proxy" tag.', $definition->getClass()));
}
if (1 === \count($tags)) {
return class_exists($tags[0]['interface']) || interface_exists($tags[0]['interface'], false) ? $tags[0]['interface'] : null;
}
$proxyInterface = 'LazyProxy';
$interfaces = '';
foreach ($tags as $tag) {
if (!isset($tag['interface'])) {
throw new \InvalidArgumentException(\sprintf('Invalid definition for service of class "%s": the "interface" attribute is missing on a "proxy" tag.', $definition->getClass()));
}
if (!interface_exists($tag['interface'])) {
throw new \InvalidArgumentException(\sprintf('Invalid definition for service of class "%s": several "proxy" tags found but "%s" is not an interface.', $definition->getClass(), $tag['interface']));
}
$proxyInterface .= '\\'.$tag['interface'];
$interfaces .= ', \\'.$tag['interface'];
}
if (!interface_exists($proxyInterface)) {
$i = strrpos($proxyInterface, '\\');
$namespace = substr($proxyInterface, 0, $i);
$interface = substr($proxyInterface, 1 + $i);
$interfaces = substr($interfaces, 2);
eval("namespace {$namespace}; interface {$interface} extends {$interfaces} {}");
}
return $proxyInterface;
}
}

View File

@@ -0,0 +1,19 @@
Copyright (c) 2004-present Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,65 @@
<?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\Bridge\ProxyManager\LazyProxy\Instantiator;
use ProxyManager\Configuration;
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy;
use ProxyManager\Proxy\LazyLoadingInterface;
use Symfony\Bridge\ProxyManager\Internal\LazyLoadingFactoryTrait;
use Symfony\Bridge\ProxyManager\Internal\ProxyGenerator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface;
trigger_deprecation('symfony/proxy-manager-bridge', '6.3', 'The "symfony/proxy-manager-bridge" package is deprecated and can be removed from your dependencies.');
/**
* Runtime lazy loading proxy generator.
*
* @author Marco Pivetta <ocramius@gmail.com>
*
* @deprecated since Symfony 6.3
*/
class RuntimeInstantiator implements InstantiatorInterface
{
private Configuration $config;
private ProxyGenerator $generator;
public function __construct()
{
$this->config = new Configuration();
$this->config->setGeneratorStrategy(new EvaluatingGeneratorStrategy());
$this->generator = new ProxyGenerator();
}
public function instantiateProxy(ContainerInterface $container, Definition $definition, string $id, callable $realInstantiator): object
{
$proxifiedClass = new \ReflectionClass($this->generator->getProxifiedClass($definition));
$factory = new class($this->config, $this->generator) extends LazyLoadingValueHolderFactory {
use LazyLoadingFactoryTrait;
};
$initializer = static function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) {
$wrappedInstance = $realInstantiator();
$proxy->setProxyInitializer(null);
return true;
};
return $factory->createProxy($proxifiedClass->name, $initializer, [
'fluentSafe' => $definition->hasTag('proxy'),
'skipDestructor' => true,
]);
}
}

View File

@@ -0,0 +1,104 @@
<?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\Bridge\ProxyManager\LazyProxy\PhpDumper;
use Laminas\Code\Generator\ClassGenerator;
use ProxyManager\GeneratorStrategy\BaseGeneratorStrategy;
use Symfony\Bridge\ProxyManager\Internal\ProxyGenerator;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
trigger_deprecation('symfony/proxy-manager-bridge', '6.3', 'The "symfony/proxy-manager-bridge" package is deprecated and can be removed from your dependencies.');
/**
* Generates dumped PHP code of proxies via reflection.
*
* @author Marco Pivetta <ocramius@gmail.com>
*
* @deprecated since Symfony 6.3
*
* @final
*/
class ProxyDumper implements DumperInterface
{
private string $salt;
private ProxyGenerator $proxyGenerator;
private BaseGeneratorStrategy $classGenerator;
public function __construct(string $salt = '')
{
$this->salt = $salt;
$this->proxyGenerator = new ProxyGenerator();
$this->classGenerator = new BaseGeneratorStrategy();
}
public function isProxyCandidate(Definition $definition, ?bool &$asGhostObject = null, ?string $id = null): bool
{
$asGhostObject = false;
return ($definition->isLazy() || $definition->hasTag('proxy')) && $this->proxyGenerator->getProxifiedClass($definition);
}
public function getProxyFactoryCode(Definition $definition, string $id, string $factoryCode): string
{
$instantiation = 'return';
if ($definition->isShared()) {
$instantiation .= \sprintf(' $container->%s[%s] =', $definition->isPublic() && !$definition->isPrivate() ? 'services' : 'privates', var_export($id, true));
}
$proxifiedClass = new \ReflectionClass($this->proxyGenerator->getProxifiedClass($definition));
$proxyClass = $this->getProxyClassName($proxifiedClass->name);
return <<<EOF
if (true === \$lazyLoad) {
$instantiation \$container->createProxy('$proxyClass', static fn () => \\$proxyClass::staticProxyConstructor(
static function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$container) {
\$wrappedInstance = $factoryCode;
\$proxy->setProxyInitializer(null);
return true;
}
));
}
EOF;
}
public function getProxyCode(Definition $definition, ?string $id = null): string
{
$code = $this->classGenerator->generate($this->generateProxyClass($definition));
$code = preg_replace('/^(class [^ ]++ extends )([^\\\\])/', '$1\\\\$2', $code);
return $code;
}
private function getProxyClassName(string $class): string
{
return preg_replace('/^.*\\\\/', '', $class).'_'.substr(hash('sha256', $class.$this->salt), -7);
}
private function generateProxyClass(Definition $definition): ClassGenerator
{
$class = $this->proxyGenerator->getProxifiedClass($definition);
$generatedClass = new ClassGenerator($this->getProxyClassName($class));
$this->proxyGenerator->generate(new \ReflectionClass($class), $generatedClass, [
'fluentSafe' => $definition->hasTag('proxy'),
'skipDestructor' => true,
]);
return $generatedClass;
}
}