1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 WEBEWEB |
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 WBW\Bundle\CoreBundle\Theme; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\CoreBundle\Navigation\NavigationTree; |
15
|
|
|
use WBW\Bundle\CoreBundle\Provider\Theme\NavigationThemeProviderInterface; |
16
|
|
|
use WBW\Bundle\CoreBundle\Service\TranslatorTrait; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Default navigation theme provider. |
20
|
|
|
* |
21
|
|
|
* @author webeweb <https://github.com/webeweb/> |
22
|
|
|
* @package WBW\Bundle\CoreBundle\Theme |
23
|
|
|
*/ |
24
|
|
|
class DefaultNavigationThemeProvider implements NavigationThemeProviderInterface { |
25
|
|
|
|
26
|
|
|
use TranslatorTrait { |
27
|
|
|
setTranslator as public; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Constructor. |
32
|
|
|
*/ |
33
|
|
|
public function __construct() { |
34
|
|
|
// NOTHING TO DO. |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritDoc} |
39
|
|
|
*/ |
40
|
|
|
public function getTree() { |
41
|
|
|
return new NavigationTree(""); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritDoc} |
46
|
|
|
*/ |
47
|
|
|
public function getView() { |
48
|
|
|
return null; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Translate. |
53
|
|
|
* |
54
|
|
|
* @param string $id The id. |
55
|
|
|
* @param array $parameters Teh parameters. |
56
|
|
|
* @param string $domain The domain. |
57
|
|
|
* @param string $locale The locale. |
58
|
|
|
* @return string Returns the translated id in case of success, id otherwise. |
59
|
|
|
*/ |
60
|
|
|
protected function translate($id, array $parameters = [], $domain = null, $locale = null) { |
61
|
|
|
|
62
|
|
|
if (null === $this->getTranslator()) { |
63
|
|
|
return $id; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
return $this->getTranslator()->trans($id, $parameters, $domain, $locale); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|