On 19.04.2011, at 23:13, Johannes Schmitt wrote:
> Controllers are a typical use case where I would use the recently added
> property injection:
>
> <service id="base_controller" abstract="true">
> <property name="securityContext" type="service" id="security.context" />
> </service>
>
> <service id="some_controller" parent="base_controller" class="MyClass">
>
> </service>
>
> abstract class BaseClass
> {
> protected $securityContext;
> }
>
> class MyClass extends BaseClass { }
>
> As far as Spring is concerned, the closest that I'm aware of to interface
> injection is auto-wiring:
> http://static.springsource.org/spring/docs/3.0.x/reference/beans.html#beans-factory-autowire
Actually I think even easier to migrate to would be to create an abstract
service "opensky.controller" which does all the "standard" injections and
simply inherit from that one. This is actually something that I am using in the
ContrainnerWrapperBundle and it makes defining a custom concrete service a lot
easier and gives you a central place to make changes for all controllers, but
still you retain the option of not inheriting in a per controller basis:
https://github.com/liip/ContainerWrapperBundle/blob/master/Resources/config/container_wrapper.xml#L13
https://github.com/liip/HelloBundle/blob/master/Resources/config/config.yml#L13
regards,
Lukas Kahwe Smith
[email protected]
--
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