- Issue created by @chesn0k
- π¬π§United Kingdom longwave UK
Not sure how you would autowire an intersection type, because we wire by interface name it can't be two at once? But union types should be possible, we should inject the first match I suppose.
- πΊπ¦Ukraine chesn0k Ukraine, Odessa
If the Drupal Core provided aliases for the serializer it would look something like this:
services: serializer: class: Symfony\Component\Serializer\Serializer arguments: [{ }, { }] Symfony\Component\Serializer\Normalizer\SerializerInterface: '@serializer' Symfony\Component\Serializer\Normalizer\DenormalizerInterface: '@serializer' Symfony\Component\Serializer\Normalizer\NormalizerInterface: '@serializer'
Assumed controller constructor:
public function __construct( protected NormalizerInterface&DenormalizerInterface $normalizer, ) {}
In this case, we can check if all interfaces of a intersection type refer to the same service. If any of the interfaces is not an alias or refers to another service throw an AutowiringFailedException.
For a union type, we can iterate over all types until the first service found.
What do you think about it?
- π¬π§United Kingdom longwave UK
I think that's pretty edge case and I still don't see an immediate use for it (we don't appear to have any constructors that would require this right now), so it depends how much overhead it adds.
- πΊπ¦Ukraine chesn0k Ukraine, Odessa
I think this would require a recursive call, okay let's skip that case for now.
- Status changed to Needs review
about 1 year ago 7:56am 30 January 2024 - Status changed to Needs work
about 1 year ago 10:54pm 23 February 2024 - πΊπΈUnited States smustgrave
Could the issue summary be updated to include proposed solution to bug?
Not sure if this is an API change.
I added the missing sections but left TBD for sections I can't answer
Test coverage appears to be there https://git.drupalcode.org/issue/drupal-3417735/-/jobs/714169