Open ad3n opened 9 years ago
Won't work unless you move that value into a parameter.
to get this working something like https://github.com/schmittjoh/JMSDiExtraBundle/pull/207 would need to be merged.
I needed it for SonataAdminBundle.
why don't you create a custom annotation for your needs? It's quite easy and gives you more flexibility https://github.com/wodka/SonataAdminBundle/blob/jms-annotation/Annotation/Admin.php
@Ener-Getick perhaps we can change how argument injection works something like:
/**
* @DI\Call({
* "service" = @DI\Argument("@foo"),
* "parameter" = @DI\Argument("%some.parameter%"),
* "string" = @DI\Argument("bar"),
* "array" = @DI\Argument({"first", "second","third"})
* })
*/
function doSomething(FooInterface $service, $parameter, $string, array $array)
{}
what do you think @schmittjoh ?
Why not add this in the code directly?
function doSomething(FooInterface $service, $parameter, $string = "bar", array $array = array('abc', 'def'))
{}
Here you have a good example of why with some new features a default value does not help:
use JMS\DiExtraBundle\Annotation as DI;
/**
* @DI\Service("api.first")
* @DI\Service("api.second")
*/
class RemoteApi
{
/**
* @DI\Call(
* {
* "service" = @DI\Argument("@foo"),
* "host" = @DI\Argument("https://first")
* },
* services = {"api.first"}
* )
*
* @DI\Call(
* {
* "service" = @DI\Argument("@foo"),
* "host" = @DI\Argument("https://second")
* },
* services = {"api.second"}
* )
*/
public function doSomething($service, $host)
{}
}
That is my service, i convert that service using DIExtraBundle and i do like it:
And got error, service appbundle\entity\propinsi is not exist