minor #21466 [DI] Remove usages of ClassExistenceResource (nicolas-grekas)
This PR was merged into the 3.3-dev branch.
Discussion
----------
[DI] Remove usages of ClassExistenceResource
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
As discussed in #21452 (see last comments)
Commits
-------
ec8f1ad453
[DI] Remove usages of ClassExistenceResource
This commit is contained in:
commit
09ec851d1a
@ -28,7 +28,6 @@ use Symfony\Component\Config\Resource\DirectoryResource;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Resource\ClassExistenceResource;
|
||||
use Symfony\Component\PropertyAccess\PropertyAccessor;
|
||||
use Symfony\Component\Serializer\Encoder\YamlEncoder;
|
||||
use Symfony\Component\Serializer\Encoder\CsvEncoder;
|
||||
@ -85,7 +84,6 @@ class FrameworkExtension extends Extension
|
||||
|
||||
$loader->load('fragment_renderer.xml');
|
||||
|
||||
$container->addResource(new ClassExistenceResource(Application::class));
|
||||
if (class_exists(Application::class)) {
|
||||
$loader->load('console.xml');
|
||||
}
|
||||
|
@ -11,14 +11,10 @@
|
||||
|
||||
namespace Symfony\Bundle\TwigBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\Config\Resource\ClassExistenceResource;
|
||||
use Symfony\Component\DependencyInjection\Alias;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
|
||||
/**
|
||||
* @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
|
||||
@ -101,18 +97,15 @@ class ExtensionPass implements CompilerPassInterface
|
||||
$container->getDefinition('twig.extension.assets')->addTag('twig.extension');
|
||||
}
|
||||
|
||||
$container->addResource(new ClassExistenceResource(YamlParser::class));
|
||||
if (class_exists(YamlParser::class)) {
|
||||
if ($container->hasDefinition('twig.extension.yaml')) {
|
||||
$container->getDefinition('twig.extension.yaml')->addTag('twig.extension');
|
||||
}
|
||||
|
||||
$container->addResource(new ClassExistenceResource(Stopwatch::class));
|
||||
if (class_exists(Stopwatch::class)) {
|
||||
if (class_exists('Symfony\Component\Stopwatch\Stopwatch')) {
|
||||
$container->getDefinition('twig.extension.debug.stopwatch')->addTag('twig.extension');
|
||||
}
|
||||
|
||||
$container->addResource(new ClassExistenceResource(ExpressionLanguage::class));
|
||||
if (class_exists(ExpressionLanguage::class)) {
|
||||
if ($container->hasDefinition('twig.extension.expression')) {
|
||||
$container->getDefinition('twig.extension.expression')->addTag('twig.extension');
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
@ -65,6 +66,9 @@ class FactoryReturnTypePass implements CompilerPassInterface
|
||||
if (is_string($factory)) {
|
||||
try {
|
||||
$m = new \ReflectionFunction($factory);
|
||||
if (false !== $m->getFileName() && file_exists($m->getFileName())) {
|
||||
$container->addResource(new FileResource($m->getFileName()));
|
||||
}
|
||||
} catch (\ReflectionException $e) {
|
||||
return;
|
||||
}
|
||||
|
@ -1007,7 +1007,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
||||
if ('service_container' === $id = (string) $reference) {
|
||||
$class = parent::class;
|
||||
} elseif (!$this->hasDefinition($id) && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
|
||||
return null;
|
||||
return;
|
||||
} else {
|
||||
$class = $parameterBag->resolveValue($this->findDefinition($id)->getClass());
|
||||
}
|
||||
|
Reference in New Issue
Block a user