CoderTn
CoderTn

Reputation: 997

Symfony 3.4 : Repository method not found

i want to add a method in my repository class ; this is my repository class 'PanierRepository' : ( path : src/techeventBundle/Repository/PanierRepository.php )

namespace techeventBundle\Repository;
use Doctrine\ORM\EntityRepository;

class PanierRepository extends EntityRepository
{
public function findAllOrderedByName($iduser){}
}

and this is my entity class called 'Panier' : (Path:src/techeventBundle/Entity/Panier.php)

namespace techeventBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Panier
 *
 * @ORM\Table(name="panier", indexes={@ORM\Index(name="userid", columns={"userid"})})
 * @ORM\Entity(repositoryClass="techeventBundle\Repository\PanierRepository")
 */
class Panier
{

and this is where i want to call this repository method , in a controller of another bundle and i have already included the entity (use techeventBundle\Entity\Panier;) : (Path : src/reservationBundle/Controller/DefaultController.php)

 $panier = $this->getDoctrine()->getRepository('techeventBundle:Panier')->findAllOrderedByName($iduser);

the repository method when i call it is not found ! Notice : i haven't generated the entities after adding the repository
please help and thanks !

Upvotes: 1

Views: 2308

Answers (1)

sensorario
sensorario

Reputation: 21620

Try with:

$this->getDoctrine()->getManager()->getRepostory( ...

enter image description here

finally, ... your code should be:

$panier = $this->getDoctrine()
    ->getManager()
    ->getRepository('techeventBundle:Panier')
    ->findAllOrderedByName($iduser);

or

$panier = $this->getDoctrine()
    ->getManager()
    ->getRepository(techeventBundle\Entity\Panier::class)
    ->findAllOrderedByName($iduser);

Upvotes: 1

Related Questions