Hello,

I have created a Bundle that allows services to be defined with
Annotations.

You can find the patch here. git://github.com/NavidMitchell/symfony.git
AnnotationsBundle.

The bundle has an extension that you can use to specify where to look
for Service annotations.

In YAML:

annotations.serviceScan:
    path: /../src/Application/HelloBundle/Service

In XML:

<annotations:serviceScan path="/../src/Application/HelloBundle/
Service" />

The path is always relative to the Kernel Root directory.

Once you specify the paths to scan you can use any of the following
annotations.

@Service  = This specifies a service to be placed into the symfony DI
container. Or can be used to specify that a service should be provided
as an argument.

@Inject = This can be used to inject a Service into another Service.
Currently this can only be used for method or constructor injection.
You can either specify the name of the service to Autowire or it will
use the name of the method parameter

@Configurator = Can be used to call to configure the service after
instantiation (the callable is passed the service instance as an
argument).

@PostConstruct = Used to annotate a method to call on the service
instance after instantiation. Arguments to pass to it can be defined
by using nested Argument annotations passed in as an array.

@FactoryMethod = Can be used to specify a method to be called to
create a instance of a service class. Must be used in conjunction of a
Service annotation. Arguments may be specified if needed. See the
Argument annotation for more detail.

@ Argument =

 * The Argument annotation serves many purposes.
 * It only can contain one value or an array of values, this is either
the value of the argument or another Annotation.
 * If this is an Array the same rules apply for all elements of the
array.
 * If it is another annotation it must be the Service annotation.
 * It can be placed on a specific class when combined with a Service
annotation to specify arguments to be passed to the constructor.
 * It can be nested on PostConstruct annotations to define arguments
to be passed to the post intialization method.


I have not provided any tests and I do not think all of the braces
follow the coding conventions.  Additionally, I have included some
code from the Addendum project for reading annotations.  I would be
happy to fix the braces and remove Addendum if the patch will be used
in Symfony 2. I just migrated this code from another project that was
using Symfony DI. I think this would be a great addition but I don't
want to spend the time if it wont be included.

Sorry for the short info. I would be happy to provide any other needed
information. I am not a big writer :)

A final thought, I think it would be great if Controllers could be
configured strictly with annotations as well. I am thinking of
providing a patch for this. Any interest?

Thanks,
Navid Mitchell

-- 
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