1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\NewsBundle\Action; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\HttpFoundation\Request; |
17
|
|
|
use Symfony\Component\HttpFoundation\Response; |
18
|
|
|
|
19
|
|
|
final class YearlyPostArchiveAction extends AbstractPostArchiveAction |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @param string $year |
23
|
|
|
* |
24
|
|
|
* @return Response |
25
|
|
|
*/ |
26
|
|
|
public function __invoke(Request $request, $year) |
27
|
|
|
{ |
28
|
|
|
$date = $this->getPostManager()->getPublicationDateQueryParts(sprintf('%d-%d-%d', $year, 1, 1), 'year'); |
29
|
|
|
|
30
|
|
|
if ($seoPage = $this->getSeoPage()) { |
31
|
|
|
$seoPage |
32
|
|
|
->addTitle($this->trans('archive_year.meta_title', [ |
33
|
|
|
'%title%' => $this->getBlog()->getTitle(), |
34
|
|
|
'%year%' => $year, |
35
|
|
|
])) |
36
|
|
|
->addMeta('property', 'og:title', $this->trans('archive_year.meta_title', [ |
37
|
|
|
'%title%' => $this->getBlog()->getTitle(), |
38
|
|
|
'%year%' => $year, |
39
|
|
|
])) |
40
|
|
|
->addMeta('name', 'description', $this->trans('archive_year.meta_description', [ |
41
|
|
|
'%title%' => $this->getBlog()->getTitle(), |
42
|
|
|
'%year%' => $year, |
43
|
|
|
'%description%' => $this->getBlog()->getDescription(), |
44
|
|
|
])) |
45
|
|
|
->addMeta('property', 'og:description', $this->trans('archive_year.meta_description', [ |
46
|
|
|
'%title%' => $this->getBlog()->getTitle(), |
47
|
|
|
'%year%' => $year, |
48
|
|
|
'%description%' => $this->getBlog()->getDescription(), |
49
|
|
|
])); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return $this->renderArchive($request, [ |
53
|
|
|
'date' => $date, |
54
|
|
|
], []); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|