|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the bootstrap-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\BootstrapBundle\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Security\Core\User\User; |
|
15
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
|
16
|
|
|
use WBW\Bundle\SyntaxHighlighterBundle\API\SyntaxHighlighterConfig; |
|
17
|
|
|
use WBW\Bundle\SyntaxHighlighterBundle\API\SyntaxHighlighterDefaults; |
|
18
|
|
|
use WBW\Bundle\SyntaxHighlighterBundle\Provider\SyntaxHighlighterStringsProvider; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Abstract wiki controller. |
|
22
|
|
|
* |
|
23
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
24
|
|
|
* @package WBW\Bundle\BootstrapBundle\Controller |
|
25
|
|
|
*/ |
|
26
|
|
|
abstract class AbstractWikiController extends AbstractBootstrapController { |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Get the Syntax Highlighter config. |
|
30
|
|
|
* |
|
31
|
|
|
* @return SyntaxHighlighterConfig Returns the SyntaxHighlighter config. |
|
32
|
|
|
*/ |
|
33
|
|
|
protected function getSyntaxHighlighterConfig() { |
|
34
|
|
|
|
|
35
|
|
|
// Get the SyntaxHighlighter strings provider. |
|
36
|
|
|
$provider = $this->get(SyntaxHighlighterStringsProvider::SERVICE_NAME); |
|
37
|
|
|
|
|
38
|
|
|
// Initialize the SyntaxHighlighter config. |
|
39
|
|
|
$config = new SyntaxHighlighterConfig(); |
|
40
|
|
|
$config->setStrings($provider->getSyntaxHighlighterStrings()); |
|
41
|
|
|
|
|
42
|
|
|
// Return the SyntaxHighlighter config. |
|
43
|
|
|
return $config; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Get the Syntax Highlighter defaults. |
|
48
|
|
|
* |
|
49
|
|
|
* @return SyntaxHighlighterDefaults Returns the SyntaxHighlighter defaults. |
|
50
|
|
|
*/ |
|
51
|
|
|
protected function getSyntaxHighlighterDefaults() { |
|
52
|
|
|
|
|
53
|
|
|
// Initialize the SyntaxHighlighter defaults. |
|
54
|
|
|
$defaults = new SyntaxHighlighterDefaults(); |
|
55
|
|
|
|
|
56
|
|
|
// Return the SyntaxHighlighter defaults. |
|
57
|
|
|
return $defaults; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Get a user. |
|
62
|
|
|
* |
|
63
|
|
|
* @return UserInterface Returns the user. |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function getUser() { |
|
66
|
|
|
return new User("anonymous", "", ["ROLE_SUPER_ADMIN", "ROLE_ADMIN", "ROLE_USER"]); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Get the user role colors. |
|
71
|
|
|
* |
|
72
|
|
|
* @return array Returns the user role colors. |
|
73
|
|
|
*/ |
|
74
|
|
|
protected function getUserRoleColors() { |
|
75
|
|
|
return [ |
|
76
|
|
|
"ROLE_SUPER_ADMIN" => "#F44336", |
|
77
|
|
|
"ROLE_ADMIN" => "#E91E63", |
|
78
|
|
|
"ROLE_USER" => "#9E9E9E", |
|
79
|
|
|
]; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Get the user role translations. |
|
84
|
|
|
* |
|
85
|
|
|
* @return array Returns the user role translations. |
|
86
|
|
|
*/ |
|
87
|
|
|
protected function getUserRoleTranslations() { |
|
88
|
|
|
return [ |
|
89
|
|
|
"ROLE_SUPER_ADMIN" => "Super administrator", |
|
90
|
|
|
"ROLE_ADMIN" => "Administrator", |
|
91
|
|
|
"ROLE_USER" => "User", |
|
92
|
|
|
]; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
} |
|
96
|
|
|
|