Repository cleanup #40 (#41)

* added base classes for repositories and queries #40
* prepared controller and repositories to use fetchByQuery() #40
* removed findAll() which has added pagination to the original doctrine method #40
This commit is contained in:
Kevin Papst
2018-01-07 11:18:42 +01:00
committed by GitHub
parent 6931302c28
commit fa8e976e76
20 changed files with 257 additions and 298 deletions

View File

@@ -22,6 +22,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use TimesheetBundle\Form\ActivityEditForm;
use TimesheetBundle\Repository\ActivityRepository;
use TimesheetBundle\Repository\Query\ActivityQuery;
/**
* Controller used to manage activities in the admin part of the site.
@@ -41,8 +42,12 @@ class ActivityController extends AbstractController
*/
public function indexAction($page)
{
$query = new ActivityQuery();
$query->setVisibility(ActivityQuery::SHOW_BOTH);
$query->setPage($page);
/* @var $entries Pagerfanta */
$entries = $this->getDoctrine()->getRepository(Activity::class)->findAll($page);
$entries = $this->getDoctrine()->getRepository(Activity::class)->findByQuery($query);
return $this->render('TimesheetBundle:admin:activity.html.twig', ['entries' => $entries]);
}

View File

@@ -20,7 +20,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use TimesheetBundle\Form\CustomerEditForm;
use TimesheetBundle\Model\Query\CustomerQuery;
use TimesheetBundle\Repository\Query\CustomerQuery;
/**
* Controller used to manage activities in the admin part of the site.

View File

@@ -21,7 +21,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use TimesheetBundle\Form\ProjectEditForm;
use TimesheetBundle\Repository\ProjectRepository;
use TimesheetBundle\Repository\Query\ProjectQuery;
/**
* Controller used to manage projects in the admin part of the site.
@@ -41,8 +41,12 @@ class ProjectController extends AbstractController
*/
public function indexAction($page)
{
$query = new ProjectQuery();
$query->setVisibility(ProjectQuery::SHOW_BOTH);
$query->setPage($page);
/* @var $entries Pagerfanta */
$entries = $this->getDoctrine()->getRepository(Project::class)->findAll($page);
$entries = $this->getDoctrine()->getRepository(Project::class)->findByQuery($query);
return $this->render('TimesheetBundle:admin:project.html.twig', ['entries' => $entries]);
}

View File

@@ -17,8 +17,8 @@ use TimesheetBundle\Entity\Project;
use TimesheetBundle\Entity\Timesheet;
use Symfony\Component\HttpFoundation\Request;
use TimesheetBundle\Form\TimesheetToolbarForm;
use TimesheetBundle\Repository\Query\TimesheetQuery;
use TimesheetBundle\Repository\TimesheetRepository;
use TimesheetBundle\Model\Query\TimesheetQuery;
/**
* Helper functions for Timesheet controller