diff --git a/src/KekRozsak/AdminBundle/Controller/DefaultController.php b/src/KekRozsak/AdminBundle/Controller/DefaultController.php index f9f1e2c..b3135f3 100644 --- a/src/KekRozsak/AdminBundle/Controller/DefaultController.php +++ b/src/KekRozsak/AdminBundle/Controller/DefaultController.php @@ -36,7 +36,12 @@ class DefaultController extends Controller throw new AccessDeniedException('Ehhez a művelethez nincs jogosultságod.'); } - $users = $this->getDoctrine()->getEntityManager()->createQuery('SELECT u FROM KekRozsakSecurityBundle:User u WHERE u.acceptedBy IS NULL')->getResult(); + $users = $this + ->getDoctrine() + ->getManager() + ->createQuery('SELECT u FROM KekRozsakSecurityBundle:User u WHERE u.acceptedBy IS NULL') + ->getResult() + ; $request = $this->getRequest(); if ($request->getMethod() == 'POST') { @@ -44,7 +49,7 @@ class DefaultController extends Controller if (($user = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:User')->findOneById($userid)) != null) { $activeUser = $this->$securityContext->getToken()->getUser(); $user->setAcceptedBy($activeUser); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($user); $em->flush(); @@ -91,7 +96,7 @@ class DefaultController extends Controller $membershipObject->setMembershipAcceptedAt(new \DateTime('now')); $membershipObject->setMembershipAcceptedBy($user); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($membershipObject); $em->flush(); diff --git a/src/KekRozsak/FrontBundle/Controller/BlogController.php b/src/KekRozsak/FrontBundle/Controller/BlogController.php index 85719ae..20576c9 100644 --- a/src/KekRozsak/FrontBundle/Controller/BlogController.php +++ b/src/KekRozsak/FrontBundle/Controller/BlogController.php @@ -18,7 +18,7 @@ class BlogController extends Controller { $query = $this ->getDoctrine() - ->getEntityManager() + ->getManager() ->createQuery(' SELECT p diff --git a/src/KekRozsak/FrontBundle/Controller/BookController.php b/src/KekRozsak/FrontBundle/Controller/BookController.php index 795aa3e..4550012 100644 --- a/src/KekRozsak/FrontBundle/Controller/BookController.php +++ b/src/KekRozsak/FrontBundle/Controller/BookController.php @@ -20,7 +20,20 @@ class BookController extends Controller */ public function listAction() { - $query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT b FROM KekRozsakFrontBundle:Book b ORDER BY b.author ASC, b.title ASC, b.year ASC'); + $query = $this + ->getDoctrine() + ->getManager() + ->createQuery(' + SELECT + b + FROM + KekRozsakFrontBundle:Book b + ORDER BY + b.author ASC, + b.title ASC, + b.year ASC + ') + ; $books = $query->getResult(); @@ -42,7 +55,7 @@ class BookController extends Controller if ($request->getMethod() == 'POST') { $newBookForm->bindRequest($request); if ($newBookForm->isValid()) { - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($book); $em->flush(); @@ -87,7 +100,7 @@ class BookController extends Controller public function ajaxDeleteBookAction(Book $book) { $copies = $book->getUsersCopies($this->get('security.context')->getToken()->getUser()); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $copies->forAll(function($key, $copy) use ($book, $em) { $book->removeCopy($copy); $em->remove($copy); @@ -110,7 +123,7 @@ class BookController extends Controller $copies = $book->getUsersCopies($user); if ($copies->count() == 0) { $copy = new BookCopy($book, $user); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($copy); $em->flush(); } @@ -129,7 +142,7 @@ class BookController extends Controller { $user = $this->get('security.context')->getToken()->getUser(); $copies = $book->getUsersCopies($user); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $copies->forAll(function($key, $copy) use ($em, $newValue) { $copy->setBorrowable($newValue); $em->persist($copy); @@ -150,7 +163,7 @@ class BookController extends Controller { $user = $this->get('security.context')->getToken()->getUser(); $copies = $book->getUsersCopies($user); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $copies->forAll(function($key, $copy) use ($em, $newValue) { $copy->setBuyable($newValue); $em->persist($copy); @@ -177,7 +190,7 @@ class BookController extends Controller $book->addWouldBorrow($user); } - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($book); $em->flush(); diff --git a/src/KekRozsak/FrontBundle/Controller/DefaultController.php b/src/KekRozsak/FrontBundle/Controller/DefaultController.php index 0e4d9dd..44102b7 100644 --- a/src/KekRozsak/FrontBundle/Controller/DefaultController.php +++ b/src/KekRozsak/FrontBundle/Controller/DefaultController.php @@ -52,7 +52,7 @@ class DefaultController extends Controller $user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt())); } - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($user); $em->flush(); } diff --git a/src/KekRozsak/FrontBundle/Controller/DocumentController.php b/src/KekRozsak/FrontBundle/Controller/DocumentController.php index baf4627..c5fd2cc 100644 --- a/src/KekRozsak/FrontBundle/Controller/DocumentController.php +++ b/src/KekRozsak/FrontBundle/Controller/DocumentController.php @@ -60,7 +60,7 @@ class DocumentController extends Controller $document->setCreatedAt(new \DateTime('now')); $document->setCreatedBy($this->get('security.context')->getToken()->getUser()); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($document); $em->flush(); @@ -98,7 +98,7 @@ class DocumentController extends Controller $document->setSlug($slugifier->slugify($document->getTitle())); // TODO: add updatedAt, updatedBy, updateReason, etc. - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($document); $em->flush(); diff --git a/src/KekRozsak/FrontBundle/Controller/EventController.php b/src/KekRozsak/FrontBundle/Controller/EventController.php index 129c3f0..0f13309 100644 --- a/src/KekRozsak/FrontBundle/Controller/EventController.php +++ b/src/KekRozsak/FrontBundle/Controller/EventController.php @@ -57,7 +57,7 @@ class EventController extends Controller $event->addAttendee($user); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($event); $em->flush(); @@ -79,11 +79,11 @@ class EventController extends Controller $realDate = null; if ($date === null) { - $query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND (e.startDate >= :day OR (e.startDate <= :day AND e.endDate >= :day))'); + $query = $this->getDoctrine()->getManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND (e.startDate >= :day OR (e.startDate <= :day AND e.endDate >= :day))'); $query->setParameter('day', new \DateTime('now'), \Doctrine\DBAL\Types\Type::DATE); } else { $realDate = \DateTime::createFromFormat('Y-m-d', $date); - $query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :day AND e.endDate >= :day) OR e.startDate = :day)'); + $query = $this->getDoctrine()->getManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :day AND e.endDate >= :day) OR e.startDate = :day)'); $query->setParameter('day', $realDate, \Doctrine\DBAL\Types\Type::DATE); } $events = $query->getResult(); @@ -104,7 +104,7 @@ class EventController extends Controller */ public function ajaxListAction(\DateTime $date) { - $query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :day AND e.endDate >= :day) OR e.startDate = :day)'); + $query = $this->getDoctrine()->getManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :day AND e.endDate >= :day) OR e.startDate = :day)'); $query->setParameter('day', $date, \Doctrine\DBAL\Types\Type::DATE); $events = $query->getResult(); diff --git a/src/KekRozsak/FrontBundle/Controller/ForumController.php b/src/KekRozsak/FrontBundle/Controller/ForumController.php index 8e03d87..9112031 100644 --- a/src/KekRozsak/FrontBundle/Controller/ForumController.php +++ b/src/KekRozsak/FrontBundle/Controller/ForumController.php @@ -45,7 +45,7 @@ class ForumController extends Controller $newTopicGroup->setCreatedAt(new \DateTime('now')); $newTopicGroup->setCreatedBy($this->get('security.context')->getToken()->getUser()); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($newTopicGroup); $em->flush(); @@ -91,7 +91,7 @@ class ForumController extends Controller $newTopic->setCreatedBy($this->get('security.context')->getToken()->getUser()); $newTopic->setTopicGroup($topicGroup); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($newTopic); $em->flush(); @@ -158,7 +158,7 @@ class ForumController extends Controller $post->setCreatedBy($this->get('security.context')->getToken()->getUser()); $post->setTopic($topic); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($post); $em->persist($topic); $em->flush(); @@ -210,7 +210,7 @@ class ForumController extends Controller } $userData->addFavouriteTopic($topic); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($userData); $em->flush(); @@ -244,7 +244,7 @@ class ForumController extends Controller } $userData->removeFavouriteTopic($topic); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($userData); $em->flush(); diff --git a/src/KekRozsak/FrontBundle/Controller/GroupController.php b/src/KekRozsak/FrontBundle/Controller/GroupController.php index 6138ad5..75dbca8 100644 --- a/src/KekRozsak/FrontBundle/Controller/GroupController.php +++ b/src/KekRozsak/FrontBundle/Controller/GroupController.php @@ -114,7 +114,7 @@ class GroupController extends Controller $membership->setMembershipAcceptedAt(new \DateTime('now')); } - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($membership); $em->flush(); @@ -160,7 +160,7 @@ class GroupController extends Controller $group->setCreatedAt(new \DateTime('now')); $group->setOpen(true); - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($group); $em->flush(); diff --git a/src/KekRozsak/FrontBundle/Twig/EventsExtension.php b/src/KekRozsak/FrontBundle/Twig/EventsExtension.php index 5bb32c5..5ef0a05 100644 --- a/src/KekRozsak/FrontBundle/Twig/EventsExtension.php +++ b/src/KekRozsak/FrontBundle/Twig/EventsExtension.php @@ -43,7 +43,25 @@ class EventsExtension extends \Twig_Extension * collection, adding each element to $monthEvents array's * 'day'th element array. */ - $query = $this->_doctrine->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :firstDay AND e.endDate >= :firstDay) OR e.startDate BETWEEN :firstDay AND :lastDay)'); + $query = $this-> + _doctrine + ->getManager() + ->createQuery(' + SELECT + e + FROM + KekRozsakFrontBundle:Event e + WHERE + e.cancelled = FALSE + AND ( + ( + e.startDate < :firstDay + AND e.endDate >= :firstDay + ) + OR e.startDate BETWEEN :firstDay AND :lastDay + ) + ') + ; $query->setParameter('firstDay', $firstDay, \Doctrine\DBAL\Types\Type::DATE); $query->setParameter('lastDay', $lastDay, \Doctrine\DBAL\Types\Type::DATE); $events = $query->getResult(); diff --git a/src/KekRozsak/SecurityBundle/Controller/DefaultController.php b/src/KekRozsak/SecurityBundle/Controller/DefaultController.php index ca832fd..66f9161 100644 --- a/src/KekRozsak/SecurityBundle/Controller/DefaultController.php +++ b/src/KekRozsak/SecurityBundle/Controller/DefaultController.php @@ -93,7 +93,7 @@ class DefaultController extends Controller $user->addRole($role); } - $em = $this->getDoctrine()->getEntityManager(); + $em = $this->getDoctrine()->getManager(); $em->persist($user); $em->flush(); diff --git a/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php b/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php index 7dc05ec..0412f5c 100644 --- a/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php +++ b/src/KekRozsak/SecurityBundle/Security/AuthSuccess.php @@ -34,7 +34,7 @@ class AuthSuccess implements AuthenticationSuccessHandlerInterface public function onSecurityAuthenticationSuccess(AuthenticationEvent $event) { $user = $event->getAuthenticationToken()->getUser(); - $em = $this->doctrine->getEntityManager(); + $em = $this->doctrine->getManager(); $user->setLastLoginAt(new \DateTime('now')); $em->persist($user); $em->flush(); @@ -43,7 +43,7 @@ class AuthSuccess implements AuthenticationSuccessHandlerInterface public function onAuthenticationSuccess(Request $request, TokenInterface $token) { $user = $token->getUser(); - $em = $this->doctrine->getEntityManager(); + $em = $this->doctrine->getManager(); $user->setLastLoginAt(new \DateTime('now')); $em->persist($user); $em->flush();