How can I get container object in repository class without passing parameter?
You will get container object as follow:
// 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 <[email protected]>
*/
private $container;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
}
Thanks
Ashok Chitroda
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments