major refactoring and cleanup

This commit is contained in:
Kevin Papst
2016-10-23 00:12:32 +02:00
parent 5a85b1d37e
commit c492d30be3
70 changed files with 1304 additions and 4027 deletions

View File

@@ -1,61 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AppBundle\Repository;
use AppBundle\Entity\Post;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Pagerfanta\Adapter\DoctrineORMAdapter;
use Pagerfanta\Pagerfanta;
/**
* FIXME CAN BE REMOVED
*
* This custom Doctrine repository contains some methods which are useful when
* querying for blog post information.
* See http://symfony.com/doc/current/book/doctrine.html#custom-repository-classes
*
* @author Ryan Weaver <weaverryan@gmail.com>
* @author Javier Eguiluz <javier.eguiluz@gmail.com>
*/
class PostRepository extends EntityRepository
{
/**
* @return Query
*/
public function queryLatest()
{
return $this->getEntityManager()
->createQuery('
SELECT p
FROM AppBundle:Post p
WHERE p.publishedAt <= :now
ORDER BY p.publishedAt DESC
')
->setParameter('now', new \DateTime())
;
}
/**
* @param int $page
*
* @return Pagerfanta
*/
public function findLatest($page = 1)
{
$paginator = new Pagerfanta(new DoctrineORMAdapter($this->queryLatest(), false));
$paginator->setMaxPerPage(Post::NUM_ITEMS);
$paginator->setCurrentPage($page);
return $paginator;
}
}

View File

@@ -14,7 +14,6 @@ namespace AppBundle\Repository;
use Doctrine\ORM\EntityRepository;
/**
* FIXME CAN BE REMOVED
*
* This custom Doctrine repository is empty because so far we don't need any custom
* method to query for application user information. But it's always a good practice