I encountered a problem validating DIC configuration here:

https://github.com/stof/DoctrineExtensionsBundle/pull/5

Specifically, because DoctrineExtensionsBundle depends on DBAL and ODM
extensions it is unable to completely validate its own configuration.
>From inside the `configLoad` method there is no way of knowing whether
the Doctrine connection a user tries to add event listeners to even
exists. It requires a further "after remove" compiler pass to
validate.

This DoctrineExtensions specific case is resolved here:

http://hile.mn/hE3LNd

This is, however, an instance of a more prevalent problem: how can a
DIC extension reliably validate its own configuration? How can it
check that all dependencies and required services have been registered
by other extensions?

One solution would be for every extension to register its own
validation in a compiler pass. This could get messy fairly quick.
Another solution is to check for service definitions at runtime and
throw exceptions then. But that's a bad user experience, and it's
something that could be validated only once at compile time instead of
during every request.

It seems like a better experience overall if there's a universal
"config validate" pass to match the universal "config merge" compiler
pass. I've made an initial implementation here:

http://hile.mn/g0bZDB

With this change, DIC extensions can (optionally) define a
`configValidate` method to match every `configLoad` (and `fooConfig` /
`fooValidate`, etc). This method is called after the 'merge',
'optimization' and 'removing' compiler passes, and handed a copy of
the ContainerBuilder. They can check dependencies here, once per
container dump, without the overhead of registering another compiler
pass for every DIC extension.

In the case of DoctrineExtensions mentioned above, this solution
provides a drop-in replacement for its own compiler pass.

Any thoughts?

-- justin

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to