I have created a method to query to database for all joining table in repository. I also have read the documentation from How to create custom repository. The method is working properly, but in PhpStorm there is a yellow warning
Method ‘findAllDetail’ not found.
How do I fix this warning?
Below is my entity:
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\InvoiceRepository")
*/
class Invoice
{
and here is the InvoiceRepository
:
namespace App\Repository;
use App\Entity\Invoice;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* @method Invoice|null find($id, $lockMode = null, $lockVersion = null)
* @method Invoice|null findOneBy(array $criteria, array $orderBy = null)
* @method Invoice[] findAll()
* @method Invoice[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class InvoiceRepository extends ServiceEntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, Invoice::class);
}
/**
* @param $value
* @return Invoice[] Returns an array of Invoice objects
*/
public function findAllDetail($value)
{
$qb = $this->createQueryBuilder('i')
/* .... */
;
return $qb->execute();
}
and here is the controller:
/**
* @Route("/invoice/review/{idInvoice}", name="submitToReview", requirements={"idInvoice"="\d+"})
* @param $idInvoice
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function submitToReview($idInvoice, \Swift_Mailer $mailer)
{
$invoice = $this->getDoctrine()->getRepository(Invoice::class)->findAllDetail($idInvoice);
/* @var $item \App\Entity\Invoice */
Tags: ph