|
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\Block\Breadcrumb; |
|
15
|
|
|
|
|
16
|
|
|
use Sonata\BlockBundle\Block\BlockContextInterface; |
|
17
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* BlockService for archive breadcrumb. |
|
21
|
|
|
* |
|
22
|
|
|
* @author Sylvain Deloux <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
class NewsArchiveBreadcrumbBlockService extends BaseNewsBreadcrumbBlockService |
|
25
|
|
|
{ |
|
26
|
|
|
public function getName() |
|
27
|
|
|
{ |
|
28
|
|
|
return 'sonata.news.block.breadcrumb_archive'; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function configureSettings(OptionsResolver $resolver): void |
|
32
|
|
|
{ |
|
33
|
|
|
parent::configureSettings($resolver); |
|
34
|
|
|
|
|
35
|
|
|
$resolver->setDefaults([ |
|
36
|
|
|
'collection' => false, |
|
37
|
|
|
'tag' => false, |
|
38
|
|
|
]); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
protected function getMenu(BlockContextInterface $blockContext) |
|
42
|
|
|
{ |
|
43
|
|
|
$menu = $this->getRootMenu($blockContext); |
|
44
|
|
|
|
|
45
|
|
|
if ($collection = $blockContext->getBlock()->getSetting('collection')) { |
|
46
|
|
|
$menu->addChild($collection->getName(), [ |
|
47
|
|
|
'route' => 'sonata_news_collection', |
|
48
|
|
|
'routeParameters' => [ |
|
49
|
|
|
'collection' => $collection->getSlug(), |
|
50
|
|
|
], |
|
51
|
|
|
'extras' => [ |
|
52
|
|
|
'translation_domain' => false, |
|
53
|
|
|
], |
|
54
|
|
|
]); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
if ($tag = $blockContext->getBlock()->getSetting('tag')) { |
|
58
|
|
|
$menu->addChild($tag->getName(), [ |
|
59
|
|
|
'route' => 'sonata_news_tag', |
|
60
|
|
|
'routeParameters' => [ |
|
61
|
|
|
'tag' => $tag->getSlug(), |
|
62
|
|
|
], |
|
63
|
|
|
'extras' => [ |
|
64
|
|
|
'translation_domain' => false, |
|
65
|
|
|
], |
|
66
|
|
|
]); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return $menu; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|