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 Sonata\IntlBundle\Templating\Helper\DateTimeHelper; |
15
|
|
|
use Sonata\NewsBundle\Model\BlogInterface; |
16
|
|
|
use Sonata\NewsBundle\Model\PostManagerInterface; |
17
|
|
|
use Symfony\Component\HttpFoundation\Request; |
18
|
|
|
use Symfony\Component\HttpFoundation\Response; |
19
|
|
|
use Symfony\Component\Translation\TranslatorInterface; |
20
|
|
|
|
21
|
|
|
final class DailyPostArchiveAction extends AbstractPostArchiveAction |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var DateTimeHelper |
25
|
|
|
*/ |
26
|
|
|
private $dateTimeHelper; |
27
|
|
|
|
28
|
|
|
public function __construct( |
29
|
|
|
BlogInterface $blog, |
30
|
|
|
PostManagerInterface $postManager, |
31
|
|
|
TranslatorInterface $translator, |
32
|
|
|
DateTimeHelper $dateTimeHelper |
33
|
|
|
) { |
34
|
|
|
parent::__construct($blog, $postManager, $translator); |
35
|
|
|
|
36
|
|
|
$this->dateTimeHelper = $dateTimeHelper; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param string $year |
41
|
|
|
* @param string $month |
42
|
|
|
* @param string $day |
43
|
|
|
* |
44
|
|
|
* @return Response |
45
|
|
|
*/ |
46
|
|
|
public function __invoke(Request $request, $year, $month, $day) |
47
|
|
|
{ |
48
|
|
|
$date = $this->getPostManager()->getPublicationDateQueryParts(sprintf('%d-%d-%d', $year, $month, $day), 'day'); |
49
|
|
|
|
50
|
|
|
if ($seoPage = $this->getSeoPage()) { |
51
|
|
|
$seoDescription = $this->getBlog()->getDescription(); |
52
|
|
|
$seoFormat = $this->dateTimeHelper->format($date, 'MMMM'); |
|
|
|
|
53
|
|
|
$seoDate = $this->dataTimeHelper->formatDate($date); |
|
|
|
|
54
|
|
|
|
55
|
|
|
$seoPage |
56
|
|
|
->setTitle($this->trans('archive_day.meta_title', [ |
57
|
|
|
'%title%' => $this->getBlog()->getTitle(), |
58
|
|
|
'%year%' => $year, |
59
|
|
|
'%month%' => $seoFormat, |
60
|
|
|
'%day%' => $day, |
61
|
|
|
'%date%' => $seoDate, |
62
|
|
|
])) |
63
|
|
|
->addMeta('property', 'og:title', $this->trans('archive_day.meta_title', [ |
64
|
|
|
'%title%' => $this->getBlog()->getTitle(), |
65
|
|
|
'%year%' => $year, |
66
|
|
|
'%month%' => $seoFormat, |
67
|
|
|
'%day%' => $day, |
68
|
|
|
'%date%' => $seoDate, |
69
|
|
|
])) |
70
|
|
|
->addMeta('name', 'description', $this->trans('archive_day.meta_description', [ |
71
|
|
|
'%title%' => $this->getBlog()->getTitle(), |
72
|
|
|
'%year%' => $year, |
73
|
|
|
'%month%' => $seoFormat, |
74
|
|
|
'%day%' => $day, |
75
|
|
|
'%description%' => $seoDescription, |
76
|
|
|
'%date%' => $seoDate, |
77
|
|
|
])) |
78
|
|
|
->addMeta('property', 'og:description', $this->trans('archive_day.meta_description', [ |
79
|
|
|
'%title%' => $this->getBlog()->getTitle(), |
80
|
|
|
'%year%' => $year, |
81
|
|
|
'%month%' => $seoFormat, |
82
|
|
|
'%day%' => $day, |
83
|
|
|
'%date%' => $seoDate, |
84
|
|
|
'%description%' => $seoDescription, |
85
|
|
|
])); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return $this->renderArchive($request, [ |
89
|
|
|
'date' => $date, |
90
|
|
|
], []); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: