-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] add configuration for the Property Accessor #7978
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
Conversation
Hmm, I think I'm -1 for this one. Configuration is meaned for global objects imo, PropertyAccessor is not a global object. |
@wouterj How do you come to this conclusion? Of course this object is global. |
@bschussek imo, PropertyAccessor is the same as the Finder object. You will instantiate a new object when using it. |
@wouterj yes but when you use it as a service it has to be configured or you should do that : |
@wouterj That's not a very good practice. In future versions of Symfony, we will support code generation in the PropertyAccessor to optimize its performance. So you will have something like this: $accessor = PropertyAccess::getPropertyAccessorBuilder()
->setCacheDir('/path/to/cache')
->enableMagicCall()
->disableMagicGetSet()
->getPropertyAccessor(); once in your application and then reuse this object. Of course you can also instantiate it when you need it, but then you need to configure it anew everytime (or lose the performance benefit). |
@@ -100,6 +100,13 @@ private function addFormSection(ArrayNodeDefinition $rootNode) | |||
->scalarNode('field_name')->defaultValue('_token')->end() | |||
->end() | |||
->end() | |||
->arrayNode('property_accessor') | |||
->info('property accessor configuration') | |||
->canBeEnabled() |
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.
canBeEnabled
is not needed here. The property_accessor service is not a service that you can remove by disabling it in the config.
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.
@stof ok how to make it optionnal ?
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.
->arrayNode('property_accessor')
->info('property accessor configuration')
->addDefaultsIfNotSet()
->children()
->booleanNode('magic_call')->defaultFalse()->end()
->end()
->end()
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.
and then simply $container->setParameter('property_accessor.magic_call.enabled', $config['property_accessor']['magic_call']);
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.
@stof thanks, fixed
@bschussek @fabpot any news on this ? |
@@ -128,7 +131,7 @@ protected static function getBundleDefaultConfig() | |||
'debug' => '%kernel.debug%', | |||
), | |||
'serializer' => array( | |||
'enabled' => false | |||
'enabled' => false |
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.
better also to put a comma at the end
Closing this PR as it landed in 2.6 via #11731 |
This allow to configure the property accessor to enable magic
__call
feature@bschussek