YearlyPostArchiveAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 38
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 30 2
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