BazingaHateoasBundle
BazingaHateoasBundle copied to clipboard
Symfony service resolver for DIExtraBundle
Hello,
I'm using this bundle for creating an api rest, and also the DIExtraBundle for service annotations.
The issue is that I must declare the service in xml for having a result from the SymfonyContainerResolver class in order of finding my custom relation provider.
I have tested with yml and it doesn't work neither. I've looked into code and I found that the SymfonyContainerResolver class uses the definition in xml for finding the service.
/**
* {@inheritdoc}
*/
public function getRelationProvider(RelationProviderConfiguration $configuration, $object)
{
if (!preg_match('/^(?P<service>[a-z0-9_.]+):(?P<method>[a-z0-9_]+)$/i', $configuration->getName(), $matches)) {
return null;
}
return array(
$this->container->get($matches['service']),
$matches['method']
);
}
is it possible of searching the service directly in the service container and not with a regular expression evaluating the xml declaration? That would be great considering the people who use DIExtraBundle or KnpRadBundle for extending annotations.
Thank you
Well, why not. Wanna work on this?
Why not. :)
El jueves, 13 de febrero de 2014, William Durand [email protected] escribió:
Well, why not. Wanna work on this?
Reply to this email directly or view it on GitHubhttps://github.com/willdurand/BazingaHateoasBundle/issues/19#issuecomment-34988469 .
"If you think a professional is expensive, wait 'til you see what an amateur can cost you!" Red Adair
@ibraelillo You should be able to specify the id of your service http://jmsyst.com/bundles/JMSDiExtraBundle/master/annotations#service
use JMS\DiExtraBundle\Annotation as DI;
/**
* @DI\Service("my_relation_provider")
*/
class CustomRelationProvider
{
}
use Hateoas\Configuration\Annotation as Hateoas;
/**
* @Hateoas\RelationProvider("my_relation_provider")
*/
class UserRepresentation
{
}
Let me know if that fixes your issue! (Sorry for the delay :-()
ping @ibraelillo