Le 01/07/2011 10:12, Benjamin Eberlei a écrit :
Yes, I know this is a problem, but even in the case currently all the
annotation classes have to be made available (through an autoloader).
Registering all possible annotations either with their class name in a
hashmap or already calling require_once on them is just another
mechanism that is not as convenient but allows more robust docblock
parsing. Also the "hack" to doctrine annotations loading is only
necessary, because these classes are organized in a non psr-0
structure. So these classes are pre-loaded in a hackish way, because
there is no other mechanism for the autoload = true case.
We already set annotations: true for validators and registering the
ExtraBundles is also a statement "pro annotation", so we do have
simple ways in Symfony2 to collect the class-names of all possible
annotations. I propose to change the following on AnnotationReader:
1. Add a method to register annotation classes:
$reader->registerAnnotation("Symfony\Bridge\Doctrine\Validator\UniqueEntity");
and $reader->registerAnnotations(array(..));
2. Add a method to register files that contain annotations:
$reader->registerAnnotationFile(".."), directly loading them via
require_once;
3. Add a method to register annotation namespaces:
$reader->registerAnnotationNamespace("Symfony\Component\Validator\Constraint",
$dir). This is used to create a silently failing PSR-0 "autoloader"
for this path + directories. It can be automatically populated from
data in the UniversalClassLoader.
4. Change the class_exists check to never use autoload = true. If a
class is part of a registered annotation namespace (only directly in
the exact namespace, no subnamspacing), try load the file based on a
silent PSR-0 autoload for it using an autoloader impl. contained in
the AnnotationReader (not the php autoloading mechanism), before
triggering the class_exists($name, false)
This way for symfony only the UniversalClassLoader data has to be used
to populate the registered annotation namespaces.
This seems good. And in Symfony, we can implement it by adding a tag on
services in which the annotation reader is injected giving the needed
data to register the annotations in the annotation_reader service. This
will require a bit work for people writing an annotation driver but they
still have to work.
This should probably be done before the Symfony2 release to avoid BC
issues after that.
Do you plan to do this in Common 2.1 or to release Common 3.0 with this
change and using it for Symfony ?
--
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