Created
February 12, 2015 17:54
-
-
Save guiwoda/ccae98110a927038d222 to your computer and use it in GitHub Desktop.
injecting doctrine Repositories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 )); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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