BlogController
Rendering Templates
return $this->render('home.html.twig', ['post'=>$post]);Fetching Services
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
public function homeAction(Post $post, LoggerInterface $logger)
{
$logger->info('We are logging!');
// ...
}/**
* @param PostCollection $posts
* @params PostRepository $postRepository
* @param PaginationService $paginationService
* @param BreadcrumbService $breadcrumbService
* @return Response
*/
public function articleThematicAction(PostCollection $posts, PostRepository $postRepository, PaginationService $paginationService, BreadcrumbService $breadcrumbService)
{
$context = ['posts'=>$posts];
if( $page = $postRepository->findByState('news_landing') ){
$context['breadcrumb'] = $breadcrumbService->build(['data'=>[[
'title'=> $page->getTitle(),
'link'=> $page->getLink()
]]]);
}
$context['pagination'] = $paginationService->build();
return $this->render('page/term.twig', $context);
}Fetching Repository
Last updated