Skip to content
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

Retrieve dependencies by FQCN where appropriate #193

Merged
merged 2 commits into from
Nov 20, 2022

Conversation

gsteel
Copy link
Member

@gsteel gsteel commented Oct 14, 2022

Q A
Documentation yes
New Feature yes

Description

This patch updates all $container->get() call sites to use a FQCN instead of a string alias. DI configuration is updated so that factories are registered against FQCN but maintains existing service aliases.

Comment on lines 36 to 44
'aliases' => [
Annotation\AnnotationBuilder::class => 'FormAnnotationBuilder',
Annotation\AttributeBuilder::class => 'FormAttributeBuilder',
FormElementManager::class => 'FormElementManager',
'FormAnnotationBuilder' => Annotation\AnnotationBuilder::class,
'FormAttributeBuilder' => Annotation\AttributeBuilder::class,
'FormElementManager' => FormElementManager::class,
],
'factories' => [
'FormAnnotationBuilder' => Annotation\BuilderAbstractFactory::class,
'FormAttributeBuilder' => Annotation\BuilderAbstractFactory::class,
'FormElementManager' => FormElementManagerFactory::class,
Annotation\AnnotationBuilder::class => Annotation\BuilderAbstractFactory::class,
Annotation\AttributeBuilder::class => Annotation\BuilderAbstractFactory::class,
FormElementManager::class => FormElementManagerFactory::class,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note here: swapping aliases and factories has a secondary effect of messing with delegators.

I am not 100% sure if delegators operate the same way on factories or aliases. Consider keeping the priority as it was before :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked him to do so: I'd rather check the delegator issue than keeping this forever

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reported in laminas/laminas-servicemanager#158

I hope to have a PR there in the next week

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still a BC break then: IMO not worth it for now, or to be extracted and targeted (just this bit) for 4.0.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a BC break only if the current laminas-servicemanager major doesn't work with both alias and aliased name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you manage to fix it, we can bump laminas-servicemanager to the fix version from laminas/laminas-servicemanager#158 and do it in a minor release.

Removing milestone here meanwhile, since it will be blocked for another while.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't I swap the aliases back for now - the rest can be merged preventing future conflicts?

IIRC, delegators simply don't work on aliases and never will: laminas/laminas-servicemanager#91

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that would be OK to do meanwhile 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Slamdunk your call here - can also discuss it tonight.

This patch updates all `$container->get()` call sites to use a FQCN instead of a string alias. DI configuration is updated so that factories are registered against FQCN but maintains existing service aliases.

Signed-off-by: George Steel <[email protected]>
@gsteel gsteel force-pushed the use-fqcn-for-container-retrieval branch from b3eeadf to 1d21cdb Compare November 20, 2022 20:57
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

src/Module.php Show resolved Hide resolved
@Ocramius Ocramius assigned Ocramius and unassigned Slamdunk Nov 20, 2022
@Ocramius Ocramius merged commit e6d71e8 into laminas:3.6.x Nov 20, 2022
@Ocramius
Copy link
Member

Thanks @gsteel!

@gsteel gsteel deleted the use-fqcn-for-container-retrieval branch November 21, 2022 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants