Fixed deprecation warning messages

This commit is contained in:
Gergely Polonkai 2013-02-26 20:40:19 +01:00
parent 919d35d082
commit cfc8622a5f
11 changed files with 65 additions and 29 deletions

View File

@ -36,7 +36,12 @@ class DefaultController extends Controller
throw new AccessDeniedException('Ehhez a művelethez nincs jogosultságod.'); 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(); $request = $this->getRequest();
if ($request->getMethod() == 'POST') { if ($request->getMethod() == 'POST') {
@ -44,7 +49,7 @@ class DefaultController extends Controller
if (($user = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:User')->findOneById($userid)) != null) { if (($user = $this->getDoctrine()->getRepository('KekRozsakSecurityBundle:User')->findOneById($userid)) != null) {
$activeUser = $this->$securityContext->getToken()->getUser(); $activeUser = $this->$securityContext->getToken()->getUser();
$user->setAcceptedBy($activeUser); $user->setAcceptedBy($activeUser);
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($user); $em->persist($user);
$em->flush(); $em->flush();
@ -91,7 +96,7 @@ class DefaultController extends Controller
$membershipObject->setMembershipAcceptedAt(new \DateTime('now')); $membershipObject->setMembershipAcceptedAt(new \DateTime('now'));
$membershipObject->setMembershipAcceptedBy($user); $membershipObject->setMembershipAcceptedBy($user);
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($membershipObject); $em->persist($membershipObject);
$em->flush(); $em->flush();

View File

@ -18,7 +18,7 @@ class BlogController extends Controller
{ {
$query = $this $query = $this
->getDoctrine() ->getDoctrine()
->getEntityManager() ->getManager()
->createQuery(' ->createQuery('
SELECT SELECT
p p

View File

@ -20,7 +20,20 @@ class BookController extends Controller
*/ */
public function listAction() 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(); $books = $query->getResult();
@ -42,7 +55,7 @@ class BookController extends Controller
if ($request->getMethod() == 'POST') { if ($request->getMethod() == 'POST') {
$newBookForm->bindRequest($request); $newBookForm->bindRequest($request);
if ($newBookForm->isValid()) { if ($newBookForm->isValid()) {
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($book); $em->persist($book);
$em->flush(); $em->flush();
@ -87,7 +100,7 @@ class BookController extends Controller
public function ajaxDeleteBookAction(Book $book) public function ajaxDeleteBookAction(Book $book)
{ {
$copies = $book->getUsersCopies($this->get('security.context')->getToken()->getUser()); $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) { $copies->forAll(function($key, $copy) use ($book, $em) {
$book->removeCopy($copy); $book->removeCopy($copy);
$em->remove($copy); $em->remove($copy);
@ -110,7 +123,7 @@ class BookController extends Controller
$copies = $book->getUsersCopies($user); $copies = $book->getUsersCopies($user);
if ($copies->count() == 0) { if ($copies->count() == 0) {
$copy = new BookCopy($book, $user); $copy = new BookCopy($book, $user);
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($copy); $em->persist($copy);
$em->flush(); $em->flush();
} }
@ -129,7 +142,7 @@ class BookController extends Controller
{ {
$user = $this->get('security.context')->getToken()->getUser(); $user = $this->get('security.context')->getToken()->getUser();
$copies = $book->getUsersCopies($user); $copies = $book->getUsersCopies($user);
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$copies->forAll(function($key, $copy) use ($em, $newValue) { $copies->forAll(function($key, $copy) use ($em, $newValue) {
$copy->setBorrowable($newValue); $copy->setBorrowable($newValue);
$em->persist($copy); $em->persist($copy);
@ -150,7 +163,7 @@ class BookController extends Controller
{ {
$user = $this->get('security.context')->getToken()->getUser(); $user = $this->get('security.context')->getToken()->getUser();
$copies = $book->getUsersCopies($user); $copies = $book->getUsersCopies($user);
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$copies->forAll(function($key, $copy) use ($em, $newValue) { $copies->forAll(function($key, $copy) use ($em, $newValue) {
$copy->setBuyable($newValue); $copy->setBuyable($newValue);
$em->persist($copy); $em->persist($copy);
@ -177,7 +190,7 @@ class BookController extends Controller
$book->addWouldBorrow($user); $book->addWouldBorrow($user);
} }
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($book); $em->persist($book);
$em->flush(); $em->flush();

View File

@ -52,7 +52,7 @@ class DefaultController extends Controller
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt())); $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->persist($user);
$em->flush(); $em->flush();
} }

View File

@ -60,7 +60,7 @@ class DocumentController extends Controller
$document->setCreatedAt(new \DateTime('now')); $document->setCreatedAt(new \DateTime('now'));
$document->setCreatedBy($this->get('security.context')->getToken()->getUser()); $document->setCreatedBy($this->get('security.context')->getToken()->getUser());
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($document); $em->persist($document);
$em->flush(); $em->flush();
@ -98,7 +98,7 @@ class DocumentController extends Controller
$document->setSlug($slugifier->slugify($document->getTitle())); $document->setSlug($slugifier->slugify($document->getTitle()));
// TODO: add updatedAt, updatedBy, updateReason, etc. // TODO: add updatedAt, updatedBy, updateReason, etc.
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($document); $em->persist($document);
$em->flush(); $em->flush();

View File

@ -57,7 +57,7 @@ class EventController extends Controller
$event->addAttendee($user); $event->addAttendee($user);
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($event); $em->persist($event);
$em->flush(); $em->flush();
@ -79,11 +79,11 @@ class EventController extends Controller
$realDate = null; $realDate = null;
if ($date === 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); $query->setParameter('day', new \DateTime('now'), \Doctrine\DBAL\Types\Type::DATE);
} else { } else {
$realDate = \DateTime::createFromFormat('Y-m-d', $date); $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); $query->setParameter('day', $realDate, \Doctrine\DBAL\Types\Type::DATE);
} }
$events = $query->getResult(); $events = $query->getResult();
@ -104,7 +104,7 @@ class EventController extends Controller
*/ */
public function ajaxListAction(\DateTime $date) 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); $query->setParameter('day', $date, \Doctrine\DBAL\Types\Type::DATE);
$events = $query->getResult(); $events = $query->getResult();

View File

@ -45,7 +45,7 @@ class ForumController extends Controller
$newTopicGroup->setCreatedAt(new \DateTime('now')); $newTopicGroup->setCreatedAt(new \DateTime('now'));
$newTopicGroup->setCreatedBy($this->get('security.context')->getToken()->getUser()); $newTopicGroup->setCreatedBy($this->get('security.context')->getToken()->getUser());
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($newTopicGroup); $em->persist($newTopicGroup);
$em->flush(); $em->flush();
@ -91,7 +91,7 @@ class ForumController extends Controller
$newTopic->setCreatedBy($this->get('security.context')->getToken()->getUser()); $newTopic->setCreatedBy($this->get('security.context')->getToken()->getUser());
$newTopic->setTopicGroup($topicGroup); $newTopic->setTopicGroup($topicGroup);
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($newTopic); $em->persist($newTopic);
$em->flush(); $em->flush();
@ -158,7 +158,7 @@ class ForumController extends Controller
$post->setCreatedBy($this->get('security.context')->getToken()->getUser()); $post->setCreatedBy($this->get('security.context')->getToken()->getUser());
$post->setTopic($topic); $post->setTopic($topic);
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($post); $em->persist($post);
$em->persist($topic); $em->persist($topic);
$em->flush(); $em->flush();
@ -210,7 +210,7 @@ class ForumController extends Controller
} }
$userData->addFavouriteTopic($topic); $userData->addFavouriteTopic($topic);
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($userData); $em->persist($userData);
$em->flush(); $em->flush();
@ -244,7 +244,7 @@ class ForumController extends Controller
} }
$userData->removeFavouriteTopic($topic); $userData->removeFavouriteTopic($topic);
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($userData); $em->persist($userData);
$em->flush(); $em->flush();

View File

@ -114,7 +114,7 @@ class GroupController extends Controller
$membership->setMembershipAcceptedAt(new \DateTime('now')); $membership->setMembershipAcceptedAt(new \DateTime('now'));
} }
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($membership); $em->persist($membership);
$em->flush(); $em->flush();
@ -160,7 +160,7 @@ class GroupController extends Controller
$group->setCreatedAt(new \DateTime('now')); $group->setCreatedAt(new \DateTime('now'));
$group->setOpen(true); $group->setOpen(true);
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($group); $em->persist($group);
$em->flush(); $em->flush();

View File

@ -43,7 +43,25 @@ class EventsExtension extends \Twig_Extension
* collection, adding each element to $monthEvents array's * collection, adding each element to $monthEvents array's
* 'day'th element array. * '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('firstDay', $firstDay, \Doctrine\DBAL\Types\Type::DATE);
$query->setParameter('lastDay', $lastDay, \Doctrine\DBAL\Types\Type::DATE); $query->setParameter('lastDay', $lastDay, \Doctrine\DBAL\Types\Type::DATE);
$events = $query->getResult(); $events = $query->getResult();

View File

@ -93,7 +93,7 @@ class DefaultController extends Controller
$user->addRole($role); $user->addRole($role);
} }
$em = $this->getDoctrine()->getEntityManager(); $em = $this->getDoctrine()->getManager();
$em->persist($user); $em->persist($user);
$em->flush(); $em->flush();

View File

@ -34,7 +34,7 @@ class AuthSuccess implements AuthenticationSuccessHandlerInterface
public function onSecurityAuthenticationSuccess(AuthenticationEvent $event) public function onSecurityAuthenticationSuccess(AuthenticationEvent $event)
{ {
$user = $event->getAuthenticationToken()->getUser(); $user = $event->getAuthenticationToken()->getUser();
$em = $this->doctrine->getEntityManager(); $em = $this->doctrine->getManager();
$user->setLastLoginAt(new \DateTime('now')); $user->setLastLoginAt(new \DateTime('now'));
$em->persist($user); $em->persist($user);
$em->flush(); $em->flush();
@ -43,7 +43,7 @@ class AuthSuccess implements AuthenticationSuccessHandlerInterface
public function onAuthenticationSuccess(Request $request, TokenInterface $token) public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{ {
$user = $token->getUser(); $user = $token->getUser();
$em = $this->doctrine->getEntityManager(); $em = $this->doctrine->getManager();
$user->setLastLoginAt(new \DateTime('now')); $user->setLastLoginAt(new \DateTime('now'));
$em->persist($user); $em->persist($user);
$em->flush(); $em->flush();