Show only events which are in the future.
This commit is contained in:
parent
29ac5c81cb
commit
d12c8d6aeb
3 changed files with 24 additions and 4 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace Hackspace\Bundle\CalciferBundle\Controller;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Hackspace\Bundle\CalciferBundle\Entity\Location;
|
||||
use Hackspace\Bundle\CalciferBundle\Entity\Tag;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -32,7 +33,14 @@ class EventController extends Controller
|
|||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entities = $em->getRepository('CalciferBundle:Event')->findBy([],['startdate' => 'ASC']);
|
||||
/** @var QueryBuilder $qb */
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb ->select(array('e'))
|
||||
->from('CalciferBundle:Event', 'e')
|
||||
->where('e.startdate >= :startdate')
|
||||
->orderBy('e.startdate')
|
||||
->setParameter('startdate',new \DateTime());
|
||||
$entities = $qb->getQuery()->execute();
|
||||
|
||||
return array(
|
||||
'entities' => $entities,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Hackspace\Bundle\CalciferBundle\Controller;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Hackspace\Bundle\CalciferBundle\Entity\Location;
|
||||
use Hackspace\Bundle\CalciferBundle\Entity\Tag;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -50,7 +50,16 @@ class LocationController extends Controller
|
|||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$entities = $em->getRepository('CalciferBundle:Event')->findBy(['locations_id' => $location->getId()],['startdate' => 'ASC']);
|
||||
/** @var QueryBuilder $qb */
|
||||
$qb = $em->createQueryBuilder();
|
||||
$qb ->select(array('e'))
|
||||
->from('CalciferBundle:Event', 'e')
|
||||
->where('e.startdate >= :startdate')
|
||||
->andWhere('e.locations_id = :location')
|
||||
->orderBy('e.startdate')
|
||||
->setParameter('startdate',new \DateTime())
|
||||
->setParameter('location',$location->getId());
|
||||
$entities = $qb->getQuery()->execute();
|
||||
|
||||
return array(
|
||||
'entities' => $entities,
|
||||
|
|
|
@ -22,6 +22,7 @@ use Jsvrcek\ICS\Model\Relationship\Organizer;
|
|||
use Jsvrcek\ICS\Utility\Formatter;
|
||||
use Jsvrcek\ICS\CalendarStream;
|
||||
use Jsvrcek\ICS\CalendarExport;
|
||||
use Symfony\Component\Validator\Constraints\DateTime;
|
||||
|
||||
/**
|
||||
* Tag controller.
|
||||
|
@ -53,7 +54,9 @@ class TagController extends Controller
|
|||
$qb ->select(array('e'))
|
||||
->from('CalciferBundle:Event', 'e')
|
||||
->join('e.tags', 't', 'WITH', $qb->expr()->in('t.id', $tag->getId()))
|
||||
->orderBy('e.startdate');
|
||||
->where('e.startdate >= :startdate')
|
||||
->orderBy('e.startdate')
|
||||
->setParameter('startdate',new \DateTime());
|
||||
$entities = $qb->getQuery()->execute();
|
||||
|
||||
return array(
|
||||
|
|
Reference in a new issue