public function authorAction(Author $author, $order, Request $request)
 {
     $push_rep = $this->getDoctrine()->getRepository('Mrk\\GitPushWatcherBundle\\Entity\\Push');
     $search = new PushSearch();
     $search->setAuthor($author->getName());
     $search->setOrderValue($order);
     if ($request->query->has('pattern')) {
         $search->setPattern($request->query->get('pattern'));
     }
     $list = $push_rep->search($search);
     $vars = ['type' => 'author', 'author' => $author, 'list' => $list, 'search' => $search];
     return $this->render('MrkGitPushWatcherBundle:Browse:index.html.twig', $vars);
 }
 public function indexAction($order, Request $request)
 {
     $push_rep = $this->getDoctrine()->getRepository('Mrk\\GitPushWatcherBundle\\Entity\\Push');
     $author_rep = $this->getDoctrine()->getRepository('Mrk\\GitPushWatcherBundle\\Entity\\Author');
     $authors = $author_rep->findAuthors();
     $search = new PushSearch();
     //$search->setType($type, $value);
     $search->setOrderValue($order);
     if ($request->query->has('author')) {
         $search->setAuthor($request->query->get('author'));
     }
     if ($request->query->has('pattern')) {
         $search->setPattern($request->query->get('pattern'));
     }
     if ($search->searchIsValid()) {
         $list = $push_rep->search($search);
     } else {
         $list = [];
     }
     $vars = ['type' => 'search', 'list' => $list, 'authors' => $authors, 'search' => $search];
     return $this->render('MrkGitPushWatcherBundle:Browse:index.html.twig', $vars);
 }
Esempio n. 3
0
 public function search(PushSearch $search)
 {
     if (!$search->searchIsValid()) {
         throw new \InvalidArgumentException("Unable to run an empty search request in " . __CLASS__);
     }
     $em = $this->getEntityManager();
     $qb = $em->createQueryBuilder();
     $qb->select('p')->from('Mrk\\GitPushWatcherBundle\\Entity\\Push', 'p');
     if ($search->hasType()) {
         $qb->andWhere('p.' . $search->getType() . ' = :value ');
         $qb->setParameter('value', $search->getValue());
     }
     if ($search->hasAuthor()) {
         $qb->andWhere('p.text LIKE :author ');
         $qb->setParameter('author', $search->getLikeAuthor());
     }
     if ($search->hasPattern()) {
         $qb->andWhere('p.text LIKE :pattern ');
         $qb->setParameter('pattern', $search->getLikePattern());
     }
     $qb->orderBy('p.' . $search->getOrderField(), $search->getOrderValue());
     return $qb->getQuery()->getResult();
 }