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