您将获得容器对象如下:
// include files to get container
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
class ClassNameRepository extends EntityRepository implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*
* @author Ashok Chitroda <ashok.chitroda@gmail.com>
*/
private $container;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢
Ashok Chitroda