-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Introducing autoconfigure: automatic _instanceof configuration #22234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
b389c64
8caad41
5b36681
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,30 +13,48 @@ | |
|
||
use Doctrine\Common\Annotations\Reader; | ||
use Symfony\Bridge\Monolog\Processor\DebugProcessor; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\Cache\Adapter\AdapterInterface; | ||
use Symfony\Component\Cache\Adapter\ArrayAdapter; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\Config\Resource\DirectoryResource; | ||
use Symfony\Component\Config\ResourceCheckerInterface; | ||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\DependencyInjection\Alias; | ||
use Symfony\Component\DependencyInjection\ChildDefinition; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Exception\LogicException; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. order |
||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage; | ||
use Symfony\Component\Finder\Finder; | ||
use Symfony\Component\Form\FormTypeGuesserInterface; | ||
use Symfony\Component\Form\FormTypeInterface; | ||
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface; | ||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; | ||
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\PropertyAccess\PropertyAccessor; | ||
use Symfony\Component\Serializer\Encoder\YamlEncoder; | ||
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface; | ||
use Symfony\Component\PropertyInfo\PropertyDescriptionExtractorInterface; | ||
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface; | ||
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; | ||
use Symfony\Component\Serializer\Encoder\CsvEncoder; | ||
use Symfony\Component\Serializer\Encoder\EncoderInterface; | ||
use Symfony\Component\Serializer\Encoder\YamlEncoder; | ||
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory; | ||
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer; | ||
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; | ||
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
use Symfony\Component\Validator\ConstraintValidatorInterface; | ||
use Symfony\Component\Validator\ObjectInitializerInterface; | ||
use Symfony\Component\WebLink\HttpHeaderSerializer; | ||
use Symfony\Component\Workflow; | ||
|
||
|
@@ -225,6 +243,43 @@ public function load(array $configs, ContainerBuilder $container) | |
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller', | ||
)); | ||
|
||
$container->registerForAutoconfiguration(Command::class) | ||
->addTag('console.command'); | ||
$container->registerForAutoconfiguration(ResourceCheckerInterface::class) | ||
->addTag('config_cache.resource_checker'); | ||
$container->registerForAutoconfiguration(ServiceSubscriberInterface::class) | ||
->addTag('container.service_subscriber'); | ||
$container->registerForAutoconfiguration(AbstractController::class) | ||
->addTag('controller.service_arguments'); | ||
$container->registerForAutoconfiguration(DataCollectorInterface::class) | ||
->addTag('data_collector'); | ||
$container->registerForAutoconfiguration(FormTypeInterface::class) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldn't be better to check if form config is enabled before registering There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's already conditionally applied so IMHO that wouldn't provide much benefit to do so. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it makes any difference, but I can see the appeal of organizing these in that way (i.e. adding the serializer-related stuff inside |
||
->addTag('form.type'); | ||
$container->registerForAutoconfiguration(FormTypeGuesserInterface::class) | ||
->addTag('form.type_guesser'); | ||
$container->registerForAutoconfiguration(CacheClearerInterface::class) | ||
->addTag('kernel.cache_clearer'); | ||
$container->registerForAutoconfiguration(CacheWarmerInterface::class) | ||
->addTag('kernel.cache_warmer'); | ||
$container->registerForAutoconfiguration(EventSubscriberInterface::class) | ||
->addTag('kernel.event_subscriber'); | ||
$container->registerForAutoconfiguration(PropertyListExtractorInterface::class) | ||
->addTag('property_info.list_extractor'); | ||
$container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class) | ||
->addTag('property_info.type_extractor'); | ||
$container->registerForAutoconfiguration(PropertyDescriptionExtractorInterface::class) | ||
->addTag('property_info.description_extractor'); | ||
$container->registerForAutoconfiguration(PropertyAccessExtractorInterface::class) | ||
->addTag('property_info.access_extractor'); | ||
$container->registerForAutoconfiguration(EncoderInterface::class) | ||
->addTag('serializer.encoder'); | ||
$container->registerForAutoconfiguration(NormalizerInterface::class) | ||
->addTag('serializer.normalizer'); | ||
$container->registerForAutoconfiguration(ConstraintValidatorInterface::class) | ||
->addTag('validator.constraint_validator'); | ||
$container->registerForAutoconfiguration(ObjectInitializerInterface::class) | ||
->addTag('validator.initializer'); | ||
|
||
if (PHP_VERSION_ID < 70000) { | ||
$this->addClassesToCompile(array( | ||
'Symfony\\Component\\Config\\ConfigCache', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<alias id="alias_1" service="service_1" public="true"/> | ||
<definition id="service_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" file=""> | ||
<definition id="service_1" class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file=""> | ||
<factory class="Full\Qualified\FactoryClass" method="get"/> | ||
</definition> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<definition class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" file=""> | ||
<definition class="Full\Qualified\Class1" public="true" synthetic="false" lazy="true" shared="true" abstract="true" autowired="false" autoconfigured="false" file=""> | ||
<factory class="Full\Qualified\FactoryClass" method="get"/> | ||
</definition> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alpha order