|
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\ClassificationBundle\Model\CollectionManagerInterface; |
|
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\HttpKernel\Exception\NotFoundHttpException; |
|
20
|
|
|
|
|
21
|
|
|
final class CollectionPostArchiveAction extends AbstractPostArchiveAction |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var CollectionManagerInterface |
|
25
|
|
|
*/ |
|
26
|
|
|
private $collectionManager; |
|
27
|
|
|
|
|
28
|
|
|
public function __construct( |
|
29
|
|
|
BlogInterface $blog, |
|
30
|
|
|
PostManagerInterface $postManager, |
|
31
|
|
|
CollectionManagerInterface $collectionManager |
|
32
|
|
|
) { |
|
33
|
|
|
parent::__construct($blog, $postManager); |
|
34
|
|
|
|
|
35
|
|
|
$this->collectionManager = $collectionManager; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param string $tag |
|
40
|
|
|
* |
|
41
|
|
|
* @return Response |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __invoke(Request $request, $tag) |
|
44
|
|
|
{ |
|
45
|
|
|
$collection = $this->collectionManager->findOneBy([ |
|
46
|
|
|
'slug' => $tag, |
|
47
|
|
|
'enabled' => true, |
|
48
|
|
|
]); |
|
49
|
|
|
|
|
50
|
|
|
if (!$collection || !$collection->getEnabled()) { |
|
51
|
|
|
throw new NotFoundHttpException('Unable to find the collection'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
return $this->renderArchive($request, ['collection' => $collection], ['collection' => $collection]); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|