mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -11,11 +11,15 @@
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
|
||||
|
||||
use Symfony\Component\Config\Loader\ParamConfigurator;
|
||||
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
|
||||
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
|
||||
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
|
||||
@@ -24,112 +28,185 @@ use Symfony\Component\ExpressionLanguage\Expression;
|
||||
*/
|
||||
class ContainerConfigurator extends AbstractConfigurator
|
||||
{
|
||||
const FACTORY = 'container';
|
||||
public const FACTORY = 'container';
|
||||
|
||||
private $container;
|
||||
private $loader;
|
||||
private $instanceof;
|
||||
private $path;
|
||||
private $file;
|
||||
private $anonymousCount = 0;
|
||||
private $env;
|
||||
|
||||
public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, $path, $file)
|
||||
public function __construct(ContainerBuilder $container, PhpFileLoader $loader, array &$instanceof, string $path, string $file, string $env = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->loader = $loader;
|
||||
$this->instanceof = &$instanceof;
|
||||
$this->path = $path;
|
||||
$this->file = $file;
|
||||
$this->env = $env;
|
||||
}
|
||||
|
||||
final public function extension($namespace, array $config)
|
||||
final public function extension(string $namespace, array $config)
|
||||
{
|
||||
if (!$this->container->hasExtension($namespace)) {
|
||||
$extensions = array_filter(array_map(function ($ext) { return $ext->getAlias(); }, $this->container->getExtensions()));
|
||||
$extensions = array_filter(array_map(function (ExtensionInterface $ext) { return $ext->getAlias(); }, $this->container->getExtensions()));
|
||||
throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s" (in "%s"). Looked for namespace "%s", found "%s".', $namespace, $this->file, $namespace, $extensions ? implode('", "', $extensions) : 'none'));
|
||||
}
|
||||
|
||||
$this->container->loadFromExtension($namespace, static::processValue($config));
|
||||
}
|
||||
|
||||
final public function import($resource, $type = null, $ignoreErrors = false)
|
||||
final public function import(string $resource, string $type = null, $ignoreErrors = false)
|
||||
{
|
||||
$this->loader->setCurrentDir(\dirname($this->path));
|
||||
$this->loader->import($resource, $type, $ignoreErrors, $this->file);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParametersConfigurator
|
||||
*/
|
||||
final public function parameters()
|
||||
final public function parameters(): ParametersConfigurator
|
||||
{
|
||||
return new ParametersConfigurator($this->container);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ServicesConfigurator
|
||||
*/
|
||||
final public function services()
|
||||
final public function services(): ServicesConfigurator
|
||||
{
|
||||
return new ServicesConfigurator($this->container, $this->loader, $this->instanceof);
|
||||
return new ServicesConfigurator($this->container, $this->loader, $this->instanceof, $this->path, $this->anonymousCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current environment to be able to write conditional configuration.
|
||||
*/
|
||||
final public function env(): ?string
|
||||
{
|
||||
return $this->env;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
final public function withPath(string $path): self
|
||||
{
|
||||
$clone = clone $this;
|
||||
$clone->path = $clone->file = $path;
|
||||
$clone->loader->setCurrentDir(\dirname($path));
|
||||
|
||||
return $clone;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a parameter.
|
||||
*/
|
||||
function param(string $name): ParamConfigurator
|
||||
{
|
||||
return new ParamConfigurator($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a service reference.
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return ReferenceConfigurator
|
||||
* @deprecated since Symfony 5.1, use service() instead.
|
||||
*/
|
||||
function ref($id)
|
||||
function ref(string $id): ReferenceConfigurator
|
||||
{
|
||||
trigger_deprecation('symfony/dependency-injection', '5.1', '"%s()" is deprecated, use "service()" instead.', __FUNCTION__);
|
||||
|
||||
return new ReferenceConfigurator($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a reference to a service.
|
||||
*/
|
||||
function service(string $serviceId): ReferenceConfigurator
|
||||
{
|
||||
return new ReferenceConfigurator($serviceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an inline service.
|
||||
*
|
||||
* @param string|null $class
|
||||
*
|
||||
* @return InlineServiceConfigurator
|
||||
* @deprecated since Symfony 5.1, use inline_service() instead.
|
||||
*/
|
||||
function inline($class = null)
|
||||
function inline(string $class = null): InlineServiceConfigurator
|
||||
{
|
||||
trigger_deprecation('symfony/dependency-injection', '5.1', '"%s()" is deprecated, use "inline_service()" instead.', __FUNCTION__);
|
||||
|
||||
return new InlineServiceConfigurator(new Definition($class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an inline service.
|
||||
*/
|
||||
function inline_service(string $class = null): InlineServiceConfigurator
|
||||
{
|
||||
return new InlineServiceConfigurator(new Definition($class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a service locator.
|
||||
*
|
||||
* @param ReferenceConfigurator[] $values
|
||||
*/
|
||||
function service_locator(array $values): ServiceLocatorArgument
|
||||
{
|
||||
return new ServiceLocatorArgument(AbstractConfigurator::processValue($values, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a lazy iterator.
|
||||
*
|
||||
* @param ReferenceConfigurator[] $values
|
||||
*
|
||||
* @return IteratorArgument
|
||||
*/
|
||||
function iterator(array $values)
|
||||
function iterator(array $values): IteratorArgument
|
||||
{
|
||||
return new IteratorArgument(AbstractConfigurator::processValue($values, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a lazy iterator by tag name.
|
||||
*
|
||||
* @param string $tag
|
||||
*
|
||||
* @return TaggedIteratorArgument
|
||||
*/
|
||||
function tagged($tag)
|
||||
function tagged_iterator(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null, string $defaultPriorityMethod = null): TaggedIteratorArgument
|
||||
{
|
||||
return new TaggedIteratorArgument($tag);
|
||||
return new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, false, $defaultPriorityMethod);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a service locator by tag name.
|
||||
*/
|
||||
function tagged_locator(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null, string $defaultPriorityMethod = null): ServiceLocatorArgument
|
||||
{
|
||||
return new ServiceLocatorArgument(new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, true, $defaultPriorityMethod));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an expression.
|
||||
*
|
||||
* @param string $expression an expression
|
||||
*
|
||||
* @return Expression
|
||||
*/
|
||||
function expr($expression)
|
||||
function expr(string $expression): Expression
|
||||
{
|
||||
return new Expression($expression);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an abstract argument.
|
||||
*/
|
||||
function abstract_arg(string $description): AbstractArgument
|
||||
{
|
||||
return new AbstractArgument($description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an environment variable reference.
|
||||
*/
|
||||
function env(string $name): EnvConfigurator
|
||||
{
|
||||
return new EnvConfigurator($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a closure service reference.
|
||||
*/
|
||||
function service_closure(string $serviceId): ClosureReferenceConfigurator
|
||||
{
|
||||
return new ClosureReferenceConfigurator($serviceId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user