Hi there!

I was working with a DependencyInjection component in Symfony 2 and
what I was really missing is possibility to combine service method
calls with passing it as argument. Something to descibe following
strucutre:

$fooService = new FooClass( $barService->getBaz() );

Of course it can be done by passing aggregate as argument and
dereferencing it withing FooClass, but still it's rather walkaround
when you want to implement your existing classes as DI services.

The solution is quite simple and I described it on my blog:
http://wrzasq.pl/blog/.html
(site in Polish, but it's just about the source code - most of the
source code is just re-implementation of Symfony's DI with just a
small piece that handle this structure)

The only important thing to notice is that calls all chained, so each
call will be executed from different context (context from each call
is the result of previous):
$object = new ServiceClass( $foo->barCall()->buzCall() )

So the question is if it's just my whim, or it could be implemented as
an enhancement since it's really small piece of code.

Also since I was digging into XML structures I faced the problem of validation:
Symfony/Components/DependencyInjection/Loader/XmlFileLoader.php rev
29807 line 248:

$path = str_replace('http://www.symfony-project.org/',
str_replace('\\', '/', $extension->getXsdValidationBasePath()).'/',
$items[$i + 1]);

What about namespaces from outside symfony-project.org that people
also want to include with local schemas? Maybe it could just replace
namespace:
$path = str_replace($items[$i], str_replace('\\', '/',
$extension->getXsdValidationBasePath()).'/', $items[$i + 1]);

or any host part:
$path = preg_replace('#^http://.*?/#', str_replace('\\', '/',
$extension->getXsdValidationBasePath()).'/', $items[$i + 1]);
--
Chillout Development, Rafał Wrzeszcz

+48 605 071 040

http://wrzasq.pl/, http://chilldev.pl/ - Tworzenie stron i aplikacji
internetowych.

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