Skip to content

Instantly share code, notes, and snippets.

@guiwoda
Created February 12, 2015 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guiwoda/ccae98110a927038d222 to your computer and use it in GitHub Desktop.
Save guiwoda/ccae98110a927038d222 to your computer and use it in GitHub Desktop.
injecting doctrine Repositories
<?php namespace App\Repositories;
// Already mapped to the Container in a ServiceProvider
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use App\Entities\Article;
class ArticleRepository extends EntityRepository
{
public function __construct(EntityManager $em)
{
parent::__construct($em, $em->getClassMetadata( Article::class ));
}
}
<?php namespace App\Services;
use App\Repositories\ArticleRepository;
class ArticleService
{
public function __construct(ArticleRepository $repository)
{
$this->repository = $repository;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment