Created
November 5, 2018 21:02
-
-
Save danabrey/39cd107da96b1eed39167a236a8dd112 to your computer and use it in GitHub Desktop.
Example custom repository for Doctrine multiple repositories from slack chat
This file contains hidden or 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\Repository; | |
use App\Entity\YourEntity; | |
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | |
use Symfony\Bridge\Doctrine\RegistryInterface; | |
/** | |
* @method YourEntity|null find($id, $lockMode = null, $lockVersion = null) | |
* @method YourEntity|null findOneBy(array $criteria, array $orderBy = null) | |
* @method YourEntity[] findAll() | |
* @method YourEntity[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |
*/ | |
class CustomRepository extends ServiceEntityRepository | |
{ | |
public function __construct(RegistryInterface $registry) | |
{ | |
parent::__construct($registry, YourEntity::class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment