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

Allow any any options for connections in Configuration #218

Closed
wants to merge 2 commits into from

Conversation

malarzm
Copy link
Member

@malarzm malarzm commented Jan 30, 2014

Fixes #215 (which points to #214 and #203).

->scalarNode('db')->end()
->end()
->end()
->variableNode('options')->defaultValue(array())->end()
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 a bad idea. It should be a prototyped array node if you want to allow any option, not a variable node. You don't want to allow anything else than arrays for options.

and using a variable will be very unfriendly to XML users, as it is not possible to define an associative array in XML (Symfony has a way to deal with it for prototyped array nodes).

the rule of thumbs is: if you start using a variable node, think twice about it. Most of the time, it is a bad choice.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing out issue with XML, I wasn't aware of that. Basically I tried to find how to allow any key in array but with no luck so I followed jmikola comment about VariableNode #203 (comment) - I'll look after prototyped array node

Copy link
Member Author

Choose a reason for hiding this comment

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

@stof is this what you've meant?

                            ->arrayNode('options')
                                ->useAttributeAsKey('name')
                                ->prototype('scalar')->end()
                            ->end()

Copy link
Member

Choose a reason for hiding this comment

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

yeah

@jmikola
Copy link
Member

jmikola commented Jan 30, 2014

@stof: I suppose in this case (using array of scalar prototypes), we leave XML users with no way to define non-scalar options for MongoClient::construct()'s options.

@malarzm: On second thought, would you be willing to revise the configuration schema to support all of the existing options? I would suggest supporting everything listed on the php.net documentation (even deprecated options for now), and removing the persist option, as it hasn't done anything since 1.2.0 of the driver (doctrine/mongodb requires >=1.2.12, anyway).

@malarzm
Copy link
Member Author

malarzm commented Jan 30, 2014

No problem, I'll do it tomorrow

@malarzm
Copy link
Member Author

malarzm commented Jan 31, 2014

Generally speaking done. readPreferenceTags is variableNode at the moment but as soon as I'll figure out how to use arrayNode and remove it if it's empty I'll change it :)

Changed VariableNode to prototyped ArrayNode

Listing all options for connection in Configuration

Removed \MongoClient consts

Changed readPreferenceTags to arrayNode
@malarzm
Copy link
Member Author

malarzm commented Jan 31, 2014

readPreferenceTags is arrayNode now

@jmikola
Copy link
Member

jmikola commented Jan 31, 2014

@malarzm: Thank you. I'll take a look at this later today.

->arrayNode('readPreferenceTags')
->performNoDeepMerging()
->prototype('array')
->prototype('scalar')->end()
Copy link
Member

Choose a reason for hiding this comment

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

is it really an array of array of scalars ?

Copy link
Member

Choose a reason for hiding this comment

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

hmm, according to the tests, the inner array seems to be associative, so you need a call to getAttributeAsKey('...') (replace ... by the name of the XML attribute used to pass the key)

@stof
Copy link
Member

stof commented Jan 31, 2014

The xml fixture file for the full config should be added IMO, so that the normalization of XML is covered as well. It would have catched some of the issues in the config tree here

and given that the bundle provide an XSD schema, it should be updated as well, otherwise XML will still be unsupported

@malarzm
Copy link
Member Author

malarzm commented Jan 31, 2014

Life would be much easier without XML configs ;) Anyway I'll create full.xml, add it to test and adjust XSD. I think I'll have problems with thenUnset() thing as I've tried setting it on almost every level which made sense but I'll give it another shot (at some moment it was almost working but not setting options at all blew everything - that's why it has landed in its current place)

@malarzm
Copy link
Member Author

malarzm commented Feb 3, 2014

full.xml is added and passing tests, XSD is slightly updated.

@jmikola
Copy link
Member

jmikola commented Feb 3, 2014

@malarzm: I'm going through this now.

@jmikola
Copy link
Member

jmikola commented Feb 4, 2014

@malarzm: Please see #219. I incorporated your commits into that PR and made some revisions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support PHP driver options in Configuration
3 participants