简体   繁体   中英

Warning: strpos() expects parameter 1 to be string, object given when calling doctrine's getRespository() method

Just passing the class name to getRepository() method

/**
 * @Rest\Route("/batches", name="isbn_list_batches", methods={"GET"})
 * @Rest\QueryParam(name="page", default=1, requirements="\d+")
 * @Rest\QueryParam(name="limit", default=10, requirements="\d+")
 *
 * @param ParamFetcher $fetcher
 * @return \Pagerfanta\Pagerfanta
 */
public function listAction(ParamFetcher $fetcher)
{
    return $this
        ->em->getRepository("App:Batch")
        ->createPaginator(
            (int)$fetcher->get('page'),
            (int)$fetcher->get('limit')
        );
}

It was working and now is throwing that error. I also tried using getRepository(Batch::class)

在此处输入图片说明

If you're using a custom query builder for the ->createPaginator() function, try to add ->getQuery() at the end of it. So for example:

createQueryBuilder()->('bla bla bla')->getQuery();

Otherwise please provide a dump by doing:

dd($this->em->getRepository(Batch::class)->findAll());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM