Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[JsonEncoder] AddJsonEncodable
attribute#59401
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
AsEncodableItem? Otherwise it does not match our As... naming or just "Encodable"? |
0e5c24d
tob70b7ea
CompareAsEncodable
attributeEncodable
attributeUh oh!
There was an error while loading.Please reload this page.
0c4c28b
to073610e
Comparesrc/Symfony/Bundle/FrameworkBundle/Tests/Functional/JsonEncoderTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
ad8e5a0
to962ae14
CompareUh oh!
There was an error while loading.Please reload this page.
962ae14
to60fd915
CompareEncodable
attributeJsonEncodable
attributeUh oh!
There was an error while loading.Please reload this page.
nicolas-grekas left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
LGTM, I like how we're using the container loading tools to do resource discovery quite seamlessly.
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/JsonEncoderTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
60fd915
toa12ad34
CompareThank you@mtarld. |
d096737
intosymfony:7.3Uh oh!
There was an error while loading.Please reload this page.
…)` and `ContainerBuilder::findExcludedServiceIds()` for auto-discovering value-objects (GromNaN)This PR was squashed before being merged into the 7.3 branch.Discussion----------[DependencyInjection] Add `Definition::addExcludedTag()` and `ContainerBuilder::findExcludedServiceIds()` for auto-discovering value-objects| Q | A| ------------- | ---| Branch? | 7.3| Bug fix? | no| New feature? | yes| Deprecations? | no| Issues | -| License | MITWe could **not** use the method `findTaggedServiceIds` in#59401 (comment), same forapi-platform/core#6943.As "using the container loading tools to do resource discovery quite seamlessly" [seems to be a good idea](#59401 (review)), this changes make it easier.I'm not closed to alternative ideas if we want to go further with this use-case.### UsageLet's create a `AppModel` attribute class and use it on any class of the project.In the extension class:```php$this->registerAttributeForAutoconfiguration(AppModel::class, static function (ChildDefinition $definition) { $definition->addExcludedTag('app.model');});```In a compiler pass:```php$classes = [];foreach($containerBuilder->findExcludedServiceIds('app.model') as $id => $tags) { $classes[] = $containerBuilder->getDefinition($id)->getClass();}$containerBuilder->setParameter('.app.model_classes', $classes);```And this parameter can be injected into a service, or directly update a service definition to inject this list of classes. The attribute parameters can be injected into the tag, and retrieved in the compiler pass, for more advanced configuration.Commits-------7a0443b [DependencyInjection] Add `Definition::addExcludedTag()` and `ContainerBuilder::findExcludedServiceIds()` for auto-discovering value-objects
Uh oh!
There was an error while loading.Please reload this page.
Add
JsonEncodable
attribute that autoconfiguresjson_encoder.encodable
tag.