Injecting service into a repository is bad practice and you shouldn't do it.
Although if want solution which will work with get->('any.service')
it will look like following:
In services.yml
app.some_service:
class: 'AppBundle\Repositories\SomeEntityRepository'
factory: ["@doctrine.orm.entity_manager", getRepository]
arguments:
- 'AppBundle\Entity\SomeEntity'
calls:
- [setContainer, ["@service_container"]]
In your repository class:
class SomeEntityRepository implements ContainerAwareInterface
{
use ContainerAwareTrait;
public function foo()
{
$bar = $this->container->get('app.bar_service');
}
}
It's also better to inject individual service rather than the service container.