Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function indexAction()
{
$events = $this->getDoctrine()
->getRepository('StfalconEventBundle:Event')
->findBy(['active' => true], ['date' => 'ASC']);
->findAllByActiveSorted(true, 'ASC');

return $this->render('ApplicationDefaultBundle:Redesign:index.html.twig', ['events' => $events]);
}
Expand All @@ -35,8 +35,8 @@ public function indexAction()
*/
public function footerPagesAction()
{
$pages = $staticPage = $this->getDoctrine()->getRepository('StfalconEventBundle:Page')
->findBy(['showInFooter' => true]);
$pages = $this->getDoctrine()->getRepository('StfalconEventBundle:Page')
->getPagesForFooter();

return $this->render('ApplicationDefaultBundle:Redesign:_footer_pages.html.twig', ['pages' => $pages]);
}
Expand Down Expand Up @@ -82,7 +82,7 @@ public function cabinetAction()
public function contactsAction()
{
$staticPage = $this->getDoctrine()->getRepository('StfalconEventBundle:Page')
->findOneBy(['slug' => 'contacts']);
->findOneBySlug('contacts');
if (!$staticPage) {
throw $this->createNotFoundException('Page not found! about');
}
Expand All @@ -100,7 +100,7 @@ public function contactsAction()
public function aboutAction()
{
$staticPage = $this->getDoctrine()->getRepository('StfalconEventBundle:Page')
->findOneBy(['slug' => 'about']);
->findOneBySlug('about');
if (!$staticPage) {
throw $this->createNotFoundException('Page not found! about');
}
Expand All @@ -118,7 +118,7 @@ public function aboutAction()
public function pageAction($slug)
{
$staticPage = $this->getDoctrine()->getRepository('StfalconEventBundle:Page')
->findOneBy(['slug' => $slug]);
->findOneBySlug($slug);
if (!$staticPage) {
throw $this->createNotFoundException(sprintf('Page not found! %s', $slug));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Stfalcon\Bundle\EventBundle\Entity\MailQueue;
use Symfony\Component\HttpFoundation\Response;

/**
* EmailSubscribe controller.
Expand All @@ -24,9 +25,7 @@ class EmailSubscribeController extends Controller
* @param int $userId
* @param int $mailId
*
* @Template()
*
* @return array
* @return Response
*/
public function unsubscribeAction($hash, $userId, $mailId = null)
{
Expand All @@ -46,7 +45,7 @@ public function unsubscribeAction($hash, $userId, $mailId = null)
}
/** @var MailQueue $mailQueue */
$mailQueue = $em->getRepository('StfalconEventBundle:MailQueue')
->findOneBy(['user' => $userId, 'mail' => $mailId]);
->findByUserAndMail($userId, $mailId);
if ($mailQueue && $subscriber->isSubscribe()) {
$mailQueue->setIsUnsubscribe();
}
Expand All @@ -55,7 +54,7 @@ public function unsubscribeAction($hash, $userId, $mailId = null)
$subscriber->setSubscribe(false);
$em->flush();

return ['hash' => $hash, 'userId' => $userId];
return $this->render('@ApplicationDefault/EmailSubscribe/unsubscribe.html.twig', ['hash' => $hash, 'userId' => $userId]);
}

/**
Expand All @@ -66,9 +65,7 @@ public function unsubscribeAction($hash, $userId, $mailId = null)
* @param int $userId
* @param string $hash
*
* @Template()
*
* @return array
* @return Response
*/
public function subscribeAction($userId, $hash)
{
Expand All @@ -84,7 +81,10 @@ public function subscribeAction($userId, $hash)
$subscriber->setSubscribe(true);
$em->flush();

return ['hash' => $hash, 'userId' => $userId];
return $this->render(
'@ApplicationDefault/EmailSubscribe/subscribe.html.twig',
['hash' => $hash, 'userId' => $userId]
);
}

/**
Expand All @@ -108,7 +108,8 @@ public function actionTrackOpenMail($userId, $hash, $mailId = null)

if ($user) {
/** @var MailQueue $mailQueue */
$mailQueue = $em->getRepository('StfalconEventBundle:MailQueue')->findOneBy(['user' => $userId, 'mail' => $mailId]);
$mailQueue = $em->getRepository('StfalconEventBundle:MailQueue')
->findByUserAndMail($userId, $mailId);
if ($mailQueue && !$mailQueue->getIsOpen()) {
/** @var Mail $mail */
$mail = $em->getRepository('StfalconEventBundle:Mail')->find($mailId);
Expand Down
98 changes: 49 additions & 49 deletions src/Application/Bundle/DefaultBundle/Controller/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Stfalcon\Bundle\EventBundle\Entity\Event;
use Stfalcon\Bundle\EventBundle\Entity\EventPage;
use Stfalcon\Bundle\SponsorBundle\Entity\Category;
use Stfalcon\Bundle\SponsorBundle\Entity\Sponsor;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -25,24 +26,18 @@ class EventController extends Controller
*
* @Route("/events", name="events")
*
* @Template("@ApplicationDefault/Redesign/Event/events.html.twig")
*
* @return array
* @return Response
*/
public function eventsAction()
{
$activeEvents = $this->getDoctrine()->getManager()
->getRepository('StfalconEventBundle:Event')
->findBy(['active' => true], ['date' => 'ASC']);

$pastEvents = $this->getDoctrine()->getManager()
->getRepository('StfalconEventBundle:Event')
->findBy(['active' => false], ['date' => 'DESC']);
$eventRepository = $this->getDoctrine()->getManager()->getRepository('StfalconEventBundle:Event');
$activeEvents = $eventRepository->findAllByActiveSorted(true, 'ASC');
$pastEvents = $eventRepository->findAllByActiveSorted(false, 'DESC');

return [
return $this->render('@ApplicationDefault/Redesign/Event/events.html.twig', [
'activeEvents' => $activeEvents,
'pastEvents' => $pastEvents,
];
]);
}

/**
Expand All @@ -53,26 +48,25 @@ public function eventsAction()
*
* @param string $eventSlug
*
* @Template("@ApplicationDefault/Redesign/Event/event.html.twig")
*
* @return array
* @return Response
*/
public function showAction($eventSlug)
{
$referralService = $this->get('stfalcon_event.referral.service');
$referralService->handleRequest($this->container->get('request_stack')->getCurrentRequest());

return $this->getEventPagesArr($eventSlug);
return $this->render(
'@ApplicationDefault/Redesign/Event/event.html.twig',
$this->getEventPagesArr($eventSlug)
);
}

/**
* Get event costs.
*
* @param Event $event
*
* @Template("@ApplicationDefault/Redesign/Event/event_price.html.twig")
*
* @return array
* @return Response
*/
public function getEventCostsAction(Event $event)
{
Expand All @@ -82,11 +76,14 @@ public function getEventCostsAction(Event $event)
$eventCurrentCost = $ticketCostRepository->getEventCurrentCost($event);
$ticketCosts = $ticketCostRepository->getEventTicketsCost($event);

return [
'ticketCosts' => $ticketCosts,
'currentPrice' => $eventCurrentCost,
'event' => $event,
];
return $this->render(
'@ApplicationDefault/Redesign/Event/event_price.html.twig',
[
'ticketCosts' => $ticketCosts,
'currentPrice' => $eventCurrentCost,
'event' => $event,
]
);
}

/**
Expand All @@ -97,23 +94,22 @@ public function getEventCostsAction(Event $event)
* @param string $eventSlug
* @param string $reviewSlug
*
* @Template("ApplicationDefaultBundle:Redesign/Speaker:report_review.html.twig")
*
* @return array
* @return Response
*/
public function showEventReviewAction($eventSlug, $reviewSlug)
{
return $this->getEventPagesArr($eventSlug, $reviewSlug);
return $this->render(
'ApplicationDefaultBundle:Redesign/Speaker:report_review.html.twig',
$this->getEventPagesArr($eventSlug, $reviewSlug)
);
}

/**
* List of sponsors of event.
*
* @param Event $event
*
* @Template("ApplicationDefaultBundle:Redesign/Partner:partners.html.twig")
*
* @return array
* @return Response
*/
public function eventPartnersAction(Event $event)
{
Expand All @@ -126,9 +122,11 @@ public function eventPartnersAction(Event $event)

$sortedPartners = [];
foreach ($partners as $key => $partner) {
$partnerCategory = $partnerCategoryRepository->find($partner['id']);
if ($partnerCategory) {
$sortedPartners[$partnerCategory->isWideContainer()][$partnerCategory->getSortOrder()][$partnerCategory->getName()][] = $partner[0];
if (isset($partner['categoryId'])) {
$partnerCategory = $partnerCategoryRepository->findById((int) $partner['categoryId']);
if ($partnerCategory instanceof Category && isset($partner[0]) && $partner[0] instanceof Sponsor) {
$sortedPartners[$partnerCategory->isWideContainer()][$partnerCategory->getSortOrder()][$partnerCategory->getName()][] = $partner[0];
}
}
}

Expand All @@ -140,7 +138,10 @@ public function eventPartnersAction(Event $event)
krsort($sortedPartners[1]);
}

return ['partners' => $sortedPartners];
return $this->render(
'ApplicationDefaultBundle:Redesign/Partner:partners.html.twig',
['partners' => $sortedPartners]
);
}

/**
Expand All @@ -158,7 +159,7 @@ public function eventPartnersAction(Event $event)
public function getModalHeaderAction($slug, $headerType)
{
$event = $this->getDoctrine()
->getRepository('StfalconEventBundle:Event')->findOneBy(['slug' => $slug]);
->getRepository('StfalconEventBundle:Event')->findOneBySlug($slug);
if (!$event) {
return new JsonResponse(['result' => false, 'error' => 'Unable to find Event by slug: '.$slug]);
}
Expand Down Expand Up @@ -186,7 +187,7 @@ public function getModalHeaderAction($slug, $headerType)
public function getEventMapPosition($slug)
{
$event = $this->getDoctrine()
->getRepository('StfalconEventBundle:Event')->findOneBy(['slug' => $slug]);
->getRepository('StfalconEventBundle:Event')->findOneBySlug($slug);
if (!$event) {
return new JsonResponse(['result' => false, 'error' => 'Unable to find Event by slug: '.$slug]);
}
Expand Down Expand Up @@ -223,7 +224,7 @@ public function userAddWantsToVisitEventAction($slug, Request $request)
$flashContent = '';
$em = $this->getDoctrine()->getManager();
$event = $this->getDoctrine()
->getRepository('StfalconEventBundle:Event')->findOneBy(['slug' => $slug]);
->getRepository('StfalconEventBundle:Event')->findOneBySlug($slug);

if (!$event) {
if ($request->isXmlHttpRequest()) {
Expand Down Expand Up @@ -275,7 +276,7 @@ public function userSubWantsToVisitEventAction($slug)
$flashContent = '';
$em = $this->getDoctrine()->getManager();
$event = $this->getDoctrine()
->getRepository('StfalconEventBundle:Event')->findOneBy(['slug' => $slug]);
->getRepository('StfalconEventBundle:Event')->findOneBySlug($slug);

if (!$event) {
return new JsonResponse(['result' => $result, 'error' => 'Unable to find Event by slug: '.$slug]);
Expand All @@ -302,9 +303,7 @@ public function userSubWantsToVisitEventAction($slug)
*
* @param string $eventSlug
*
* @Template("ApplicationDefaultBundle:Redesign:venue_review.html.twig")
*
* @return array
* @return Response
*/
public function showEventVenuePageAction($eventSlug)
{
Expand All @@ -316,7 +315,10 @@ public function showEventVenuePageAction($eventSlug)
$newText = $resultArray['venuePage']->getTextNew();
$text = isset($newText) && !empty($newText) ? $newText : $resultArray['venuePage']->getText();

return array_merge($resultArray, ['text' => $text]);
return $this->render(
'ApplicationDefaultBundle:Redesign:venue_review.html.twig',
array_merge($resultArray, ['text' => $text])
);
}

/**
Expand All @@ -325,14 +327,12 @@ public function showEventVenuePageAction($eventSlug)
* @param string $eventSlug
* @param string $pageSlug
*
* @Template("ApplicationDefaultBundle:Redesign:static.page.html.twig")
*
* @return array
* @return Response
*/
public function showEventPageInStaticAction($eventSlug, $pageSlug)
{
$event = $this->getDoctrine()
->getRepository('StfalconEventBundle:Event')->findOneBy(['slug' => $eventSlug]);
->getRepository('StfalconEventBundle:Event')->findOneBySlug($eventSlug);
if (!$event) {
throw $this->createNotFoundException(sprintf('Unable to find event by slug: ', $eventSlug));
}
Expand All @@ -353,7 +353,7 @@ public function showEventPageInStaticAction($eventSlug, $pageSlug)
$newText = $myPage->getTextNew();
$text = isset($newText) && !empty($newText) ? $newText : $myPage->getText();

return ['text' => $text];
return $this->render('ApplicationDefaultBundle:Redesign:static.page.html.twig', ['text' => $text]);
}

/**
Expand Down
34 changes: 34 additions & 0 deletions src/Stfalcon/Bundle/EventBundle/Repository/EventRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,40 @@
*/
class EventRepository extends EntityRepository
{
/**
* @param bool $active
* @param string $sort
*
* @return array|null
*/
public function findAllByActiveSorted($active = true, $sort = 'ASC')
{
$qb = $this->createQueryBuilder('e');
$qb->where($qb->expr()->eq('e.active', ':active'))
->setParameter('active', $active)
->orderBy('e.date', $sort)
;

return $qb->getQuery()->getResult();
}

/**
* @param string $slug
*
* @return mixed
*
* @throws \Doctrine\ORM\NonUniqueResultException
*/
public function findOneBySlug($slug)
{
$qb = $this->createQueryBuilder('e');
$qb->where($qb->expr()->eq('e.slug', ':slug'))
->setParameter('slug', $slug)
;

return $qb->getQuery()->getOneOrNullResult();
}

/**
* @param User $user
* @param bool $active
Expand Down
Loading