Cześć.
Mam pytanie jak można przekazać zmienna z kontrolera do repsitory mój kod:
Constoller
/**
* @Route("/seartch" , name="news_seartch")
* @return \Symfony\Component\HttpFoundation\Response
*
* @param Request $request
*/
public function seartchAction(Request $request)
{
if($request->request->get('found')){
$found = $request->request->get('found');
$entityManager = $this ->getDoctrine()->getManager();
$news = $entityManager
->getRepository(Newstleter::class)
->findMyOrdered();
return $this->render("view/test.html.twig",["news"=>$news]);
}
return $this->redirectToRoute('');
}
Respository
class NewsRepository extends \Doctrine\ORM\EntityRepository
{
/**
* @param $found
* @return array
*/
public function findMyOrdered($found)
{
return $this
->getEntityManager()
->createQuery(
"SELECT n
FROM AppBundle:Newstleter
n WHERE n.title =:found"
)
//->setParameter("sertch",'%r%')
->setParameter('found',$found)
->getResult();
}
}