Skip to content

Instantly share code, notes, and snippets.

@danabrey
Created November 5, 2018 21:02
Show Gist options
  • Save danabrey/39cd107da96b1eed39167a236a8dd112 to your computer and use it in GitHub Desktop.
Save danabrey/39cd107da96b1eed39167a236a8dd112 to your computer and use it in GitHub Desktop.
Example custom repository for Doctrine multiple repositories from slack chat
<?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