Fix PHP syntax errors.

This commit is contained in:
Pol Dellaiera
2021-06-08 13:59:06 +02:00
parent a7af30c378
commit 39dcc59a0c
2 changed files with 30 additions and 29 deletions

View File

@@ -8,21 +8,21 @@ use Symfony\Component\HttpFoundation\Request;
class ItemController extends Controller {
public function yourAction()
public function yourAction()
{
$em = $this->getDoctrine()->getManager();
// first, get the number of total item are available
$total = $em
->createQuery("SELECT COUNT (item.id) FROM ChillMyBundle:Item item")
->getSingleScalarResult();
// get the PaginatorFactory
$paginatorFactory = $this->get('chill_main.paginator_factory');
// create a pagination instance. This instance is only valid for
// create a pagination instance. This instance is only valid for
// the current route and parameters
$paginator = $paginatorFactory->create($total);
// launch your query on item. Limit the query to the results
// for the current page using the paginator
$items = $em->createQuery("SELECT item FROM ChillMyBundle:Item item WHERE <your clause>")
@@ -30,12 +30,12 @@ class ItemController extends Controller {
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())
// use the paginator to get the number of items to display
->setMaxResults($paginator->getItemsPerPage());
return $this->render('ChillMyBundle:Item:list.html.twig', array(
'items' => $items,
'paginator' => $paginator
);
)
);
}
}