Aloha,

Following the model of the Security Firewall the plan is to migrate 
DoctrineBundle to using DIC templates in order to enable developers to modify 
the default configuration structure for auto generated services [1]. This also 
greatly simplifies the code in the Extensions.

I would like to go a step further and allow the reuse of "templates" inside the 
DIC config itself without requiring an Extension for this. The use case is 
anywhere one needs to define multiple services which only differentiate on the 
arguments. For example there was been some discussion about people who do not 
like to inject the container to have an MVCTools service they can inject.

Also the View layer currently under review supports injecting parameters [2] 
straight into the layout without having them going through the controller at 
all (for example useful to pass some URL's to the frontend to be used in 
generated Javascript code or some theming (for example automatically theming 
the site on the staging server with different colors than the production server 
to prevent accidental changes).

Here it might be useful to not have to pass in the same parameters in all 
cases, without having to tediously replicate the entire service configuration 
again. More over it can be hard to keep an overview of all these minor 
variations leading to potentially redundant service definitions.

services:
    MyService:
        class: Application\MyBundle\Foo\Bar
        arguments:
            first: @first
            second: @second
            third: [ding, dong, ping, pong]
            fourth: ''
        shared: true
        tag: template
    MyDefault:
        class: Application\MyBundle\Controller\DefaultController
        arguments:
            view: @MyService [ fourth: 'this is just a test' ]
        shared: true
    MyDefault2:
        class: Application\MyBundle\Controller\OtherController
        arguments:
            view: @MyService [ second: @otherstuff ]
        shared: true
    MyDefault3:
        class: Application\MyBundle\Controller\OtherOtherController
        arguments:
            view: @MyService [ second: @otherstuff ]
        shared: true

This would define two services each with slight modifications in the arguments:
- MyDefault would have a different value injected as the fourth argument to 
MyService
- MyDefault2 would have a different service injected as the second argument to 
MyService
- MyDefault3 would have a different service injected as the second argument to 
MyService

The names of these services will actually be 'MyService_'.md5(" fourth: 'this 
is just a test' ]") and 'MyService_'.md5([ second: @otherstuff ]") and the DIC 
would not complain about name collisions. As a result in the above example only 
2 services would be defined on the fly.

Furthermore since "MyService" is tagged with "template" it would automatically 
be removed before the DIC is dumped [3]. 

regards,
Lukas Kahwe Smith
[email protected]

[1] http://trac.symfony-project.org/wiki/IRCLogs20101118
[2] http://pastie.org/1352992
[3] Makes me wonder if "tag" shouldn't be "tags" to support multiple tags.

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