Skip to content

Instantly share code, notes, and snippets.

@morontt
Last active October 25, 2016 14:48
Show Gist options
  • Save morontt/ecdcc638836e4f91d510901f0557f3a8 to your computer and use it in GitHub Desktop.
Save morontt/ecdcc638836e4f91d510901f0557f3a8 to your computer and use it in GitHub Desktop.
Service Container in Repository
<?php
namespace SheimarkBundle\Entity\Repository;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\DependencyInjection\ContainerInterface;
class SalesTaxCodeRepository extends EntityRepository
{
/**
* @var ContainerInterface
*/
protected $container;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
}
services:
sheimark.sales_repository:
class: SheimarkBundle\Entity\Repository\SalesTaxCodeRepository
factory: ['@doctrine.orm.entity_manager', getRepository]
arguments:
- "SheimarkBundle:SalesTaxCode"
calls:
- [ setContainer, ["@service_container"]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment