8000 [FrameworkBundle] Deprecated form types as services by HeahDude · Pull Request #18343 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Deprecated form types as services #18343

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

Closed

Conversation

HeahDude
Copy link
Contributor
Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets ~
License MIT
Doc PR ~

These services are not used anymore and should be removed in 4.0 (ref #15079).

@@ -43,6 +43,7 @@
<service id="form.type_guesser.validator" class="Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser">
<tag name="form.type_guesser" />
<argument type="service" id="validator.mapping.class_metadata_factory" />
<deprecated>"The \"%service_id%\" service is deprecated since Symfony 3.1 and will be removed in 4.0."</deprecated>
Copy link
Contributor

Choose a reason for hiding this comment

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

why the " delimiters ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Properly copied from YAML :) @HeahDude you don't need to quote the message in XML or escape quotes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, and I think it's gonna fail (it should, as it shouldn't detect the exact "%service_id%" if my memory serves me right)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sstok @Taluu Thanks for the review :)

Are you sure, I actually did not copy it from yaml :) I did it because tests were failing because of that :/

Copy link
Member

Choose a reason for hiding this comment

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

This service should not be deprecated, as it has a dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried the SE without registering it and it worked. If the extension is lazy loaded so are the types.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok thanks for the heads-up :)

Copy link
Member

Choose a reason for hiding this comment

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

@HeahDude if you remove this service, type guessing will not work properly anymore (it won't read validator metadata anymore).
Using the SE alone would not show it, as there is nothing in it relying on this feature (you have to write code using forms).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stof agreed on this one, but the others can safely be deprecated IMHO.

@stof
Copy link
Member
stof commented Mar 29, 2016

Status: needs work

@HeahDude
Copy link
8000
Contributor Author

Status: Needs Review

@HeahDude HeahDude force-pushed the deprecate-form_types_as_services branch 2 times, most recently from 10e816b to 1bd0365 Compare March 29, 2016 12:11
@@ -6,6 +6,7 @@ CHANGELOG

* Added `Controller::json` to simplify creating JSON responses when using the Serializer component
* Deprecated absolute template paths support in the template name parser
* Deprecated services for core form types, form type extensions and form guessers
Copy link
Member

Choose a reason for hiding this comment

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

form type extensions and form guessers are not deprecated (they cannot be)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I missed that.

@HeahDude
Copy link
Contributor Author

Status: Needs Work

@HeahDude HeahDude force-pushed the deprecate-form_types_as_services branch from 1bd0365 to 7989b03 Compare March 29, 2016 14:53
@HeahDude
Copy link
Contributor Author

Ok comments addressed, should be good to merge now. Thanks again @Taluu @stof for the reviews.

Status: Needs Review

@@ -6,6 +6,7 @@ CHANGELOG

* Added `Controller::json` to simplify creating JSON responses when using the Serializer component
* Deprecated absolute template paths support in the template name parser
* Deprecated services for core form types and core form type extensions without dependencies
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 wrong for type extensions. Type extensions always need to be registered

@@ -179,9 +208,11 @@
</service>
<service id="form.type_extension.repeated.validator" class="Symfony\Component\Form\Extension\Validator\Type\RepeatedTypeValidatorExtension">
<tag name="form.type_extension" extended-type="Symfony\Component\Form\Extension\Core\Type\RepeatedType" />
<deprecated>The "%service_id%" service is deprecated since Symfony 3.1 and will be removed in 4.0.</deprecated>
Copy link
Member

Choose a reason for hiding this comment

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

You cannot deprecate these services. If an extension is not registered, it cannot extend the logic of the form type (and there is no way to automatically discover extensions based on the form type class name)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stof I don't think they have to since they don't have strict dependencies.

See https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php#L54.

Right ?

Copy link
Member

Choose a reason for hiding this comment

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

Please stop linking to form extensions to justify that these services are useless. As I already said many times, form extensions are NOT registered when using the fullstack framework, in favor of lazy-loading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely understood. Sorry for the confusion about this, thanks for clarifying it... again :)

@HeahDude
Copy link
Contributor Author

Some tests are failing :/

Status: Needs Work

@HeahDude
Copy link
Contributor Author

@stof Final call: I figured that actually all form types are lazy loaded using the only DependencyInjectionExtension in the form registry of the SE thanks to the framework bundle and that's why I get those errors...

We cannot deprecate them at all. Sorry again for this confusion, I learned something important here!

Closing though.

@HeahDude HeahDude closed this Mar 29, 2016
@stof
Copy link
Member
stof commented Mar 29, 2016

@HeahDude actually, for any type not using dependencies, we can deprecate services, as form types are auto-registered on first usage in the new system (as the identifier is the class name, we can auto-register them when there is no dependency)

@stof
Copy link
Member
stof commented Mar 29, 2016

however, marking services as deprecated while keeping them to preserve BC would indeed lead to warnings for any usage of the form types, as they would be registered using the services

@HeahDude
Copy link
Contributor Author

That's right, thank you so much for your feedback.

I think we might be able to optimize things here, thanks to the refactoring of 2.8. I'm looking into it.

@HeahDude
Copy link
Contributor Author

@stof I've learned how it actually is very well optimised already and I find a way to get rid of those errors by just removing the tag. So we can deprecate them and keep them in case somebody has the weird idea to use them.

What do you think ?

@HeahDude
Copy link
Contributor Author

See #18356.

@HeahDude
Copy link
Contributor Author

@stof thanks again for your patience and your lead on this, the config of the form registry is now crystal clear :)

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.

7 participants
0