Chce zedytować trochę demo aplikacje i już na starcie pojawił się problem. Chce zmienić homepage ze statycznej strony, na główną strone w blogu.Mam następujacy Error:
Controller "AppBundle\Controller\BlogController::indexAction()" requires that you provide a value for the "$page" argument (because there is no default value or because there is a non optional argument after this one).
Kod akcji controllera wygląda następująco:
/**
* @Route("/", name="blog_index", defaults={"page" = 1})
* @Route("/page/{page}", name="blog_index_paginated", requirements={"page" : "\d+"})
*/
public function indexAction($page)
{
$query = $this->getDoctrine()->getRepository('AppBundle:Post')->queryLatest();
$paginator = $this->get('knp_paginator');
$posts = $paginator->paginate($query, $page, Post::NUM_ITEMS);
$posts->setUsedRoute('blog_index_paginated');
return $this->render('blog/index.html.twig', array('posts' => $posts));
}
app/config/routing.yml
app:
resource: @AppBundle/Controller/
type: annotation
prefix: /{_locale}
requirements:
_locale: %app_locales%
defaults:
_locale: %locale%
homepage:
path: /{_locale}
requirements:
_locale: %app_locales%
defaults:
_controller: AppBundle:Blog:index
#_controller: FrameworkBundle:Template:template
#template: 'default/homepage.html.twig'
_locale: "%locale%"
Wiem że moge zmienić w metodzie $page = 1 ale wydaje mi sie że to nie jest dobra praktyka. Ktoś pomoże?