Le 09/05/2011 20:22, Alan Gabriel Bem a écrit :
Thank you for the response
W dniu poniedziałek, 9 maja 2011, 19:17:40 UTC+2 użytkownik Christophe
COEVOET napisał:
Le 09/05/2011 18:13, Alan Gabriel Bem a écrit :
The namespace is used to identify the configuration used by this
extension. This is mandatory to be able to use an XML config file.
The XSD is not mandatory. You just don't have the XSD validation
if it is not provided.
Requiring to have an XSD would mean that each bundle developer
providing a semantic configuration would have to provide an XSD
file. But this requires knowing the XSD syntax and writing it for
XML users whereas using validations rules in a Configuration class
is more powerful: it works also for YAML config, it validates the
merged configuration (a required key is not required in *all*
files but in the merged config). XSD validation is definetly not
the better solution when merging some configuration files.
I didn't write anything about requiring XSD. Maybe I was unclear -
sorry about that. What I meant is that XML Schema validation proceed
somewhat magically and it occures only when schemaLocation is defined
for validated namespace. Here's sample:
# config1.xml
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
>
<framework:config secret="%secret%" charset="%kernel.charset%">
<framework:csrf-protection enabled="true" />
<framework:router resource="%kernel.root_dir%/config/routing.xml" />
<framework:validation enabled="true" annotations="true" />
<framework:templating>
<framework:engine>twig</framework:engine>
</framework:templating>
<framework:session default-locale="%locale%" lifetime="3600"
auto-start="true" />
</framework:config>
</container>
# config2.xml
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/symfonyhttp://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
>
<framework:config secret="%secret%" charset="%kernel.charset%">
<framework:csrf-protection enabled="true" />
<framework:router resource="%kernel.root_dir%/config/routing.xml" />
<framework:validation enabled="true" annotations="true" />
<framework:templating>
<framework:engine>twig</framework:engine>
</framework:templating>
<framework:session default-locale="%locale%" lifetime="3600"
auto-start="true" />
</framework:config>
</container>
framework namespace in config2.xml won't be validated
againstFrameworkBundles' xsd file (symfony-1.0.xsd), on the other
hand in config1.xml it will be. Why? Because XmlConfigLoader takes
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd from
schemaLocations attribute and translates to local xsd filepath. Which
is odd for me. Extensions can provide this path on their own.
Why would it be done in the loader ?
Because *only* XmlConfigLoader lookup extensions by their namespaces.
*Only *there you can see something like that:
$this->container->getExtension('http://symfony.com/schema/dic/symfony');
As I said, the loaded configuration is *not* sent to the extension
direcly but stored in the ContainerBuilder.
Thus, the XmlFileLoader (and no XmlConfigLoader which does not exist)
does not call /getExtension/ but /loadFromExtension/
It seems to me that you are talking about far outdated code here as this
is the case since July
--
Christophe | Stof
--
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