Mon super article 2
Le super résumé
Choose your language
3 жовтня 2023 р. о 09:52:04 Tom Doe
Le super résumé
2 жовтня 2023 р. о 13:04:51 Tom Doe
Le super résumé
Цей демо додаток створено на основі Symfony фреймворку для того, щоб показати рекомендований спосіб розробки Symfony додатків.
Для додаткової інформації зверніться до Symfony документації.
Натисніть на цю кнопку для перегляду вихідного коду контролеру та шаблону, які використовувалися для побудови цієї сторінки.
src/Controller/BlogController.php at line 51
/**
* NOTE: For standard formats, Symfony will also automatically choose the best
* Content-Type header for the response.
*
* See https://symfony.com/doc/current/routing.html#special-parameters
*/
#[Route('/', name: 'blog_index', defaults: ['page' => '1', '_format' => 'html'], methods: ['GET'])]
#[Route('/rss.xml', name: 'blog_rss', defaults: ['page' => '1', '_format' => 'xml'], methods: ['GET'])]
#[Route('/page/{page<[1-9]\d{0,8}>}', name: 'blog_index_paginated', defaults: ['_format' => 'html'], methods: ['GET'])]
#[Cache(smaxage: 10)]
public function index(Request $request, int $page, string $_format, PostRepository $posts, TagRepository $tags): Response
{
$tag = null;
if ($request->query->has('tag')) {
$tag = $tags->findOneBy(['name' => $request->query->get('tag')]);
}
$latestPosts = $posts->findLatest($page, $tag);
// Every template name also has two extensions that specify the format and
// engine for that template.
// See https://symfony.com/doc/current/templates.html#template-naming
return $this->render('blog/index.'.$_format.'.twig', [
'paginator' => $latestPosts,
'tagName' => $tag?->getName(),
]);
}