|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of Sulu. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) MASSIVE ART WebServices GmbH |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the MIT license that is bundled |
|
9
|
|
|
* with this source code in the file LICENSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sulu\Bundle\CommentBundle\Admin; |
|
13
|
|
|
|
|
14
|
|
|
use Sulu\Bundle\AdminBundle\Admin\Admin; |
|
15
|
|
|
use Sulu\Bundle\AdminBundle\Navigation\Navigation; |
|
16
|
|
|
use Sulu\Bundle\AdminBundle\Navigation\NavigationItem; |
|
17
|
|
|
use Sulu\Component\Security\Authorization\PermissionTypes; |
|
18
|
|
|
use Sulu\Component\Security\Authorization\SecurityCheckerInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Integrates sulu_comment into sulu-admin. |
|
22
|
|
|
*/ |
|
23
|
|
|
class CommentAdmin extends Admin |
|
24
|
|
|
{ |
|
25
|
|
|
const COMMENT_SECURITY_CONTEXT = 'sulu.comment.comments'; |
|
26
|
|
|
|
|
27
|
|
|
const THREAD_SECURITY_CONTEXT = 'sulu.comment.threads'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var SecurityCheckerInterface |
|
31
|
|
|
*/ |
|
32
|
|
|
private $securityChecker; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param SecurityCheckerInterface $securityChecker |
|
36
|
|
|
* @param string $title |
|
37
|
|
|
*/ |
|
38
|
|
|
public function __construct(SecurityCheckerInterface $securityChecker, $title) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->securityChecker = $securityChecker; |
|
41
|
|
|
|
|
42
|
|
|
$rootNavigationItem = new NavigationItem($title); |
|
43
|
|
|
$section = new NavigationItem('navigation.modules'); |
|
44
|
|
|
$section->setPosition(20); |
|
45
|
|
|
|
|
46
|
|
|
$commentModule = new NavigationItem('sulu_comment.comments'); |
|
47
|
|
|
$commentModule->setPosition(9); |
|
48
|
|
|
$commentModule->setIcon('commenting'); |
|
49
|
|
|
|
|
50
|
|
View Code Duplication |
if ($this->securityChecker->hasPermission(self::COMMENT_SECURITY_CONTEXT, PermissionTypes::VIEW)) { |
|
51
|
|
|
$comments = new NavigationItem('sulu_comment.comments'); |
|
52
|
|
|
$comments->setPosition(10); |
|
53
|
|
|
$comments->setAction('comments'); |
|
54
|
|
|
|
|
55
|
|
|
$commentModule->addChild($comments); |
|
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
View Code Duplication |
if ($this->securityChecker->hasPermission(self::THREAD_SECURITY_CONTEXT, PermissionTypes::VIEW)) { |
|
59
|
|
|
$threads = new NavigationItem('sulu_comment.threads'); |
|
60
|
|
|
$threads->setPosition(20); |
|
61
|
|
|
$threads->setAction('threads'); |
|
62
|
|
|
|
|
63
|
|
|
$commentModule->addChild($threads); |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
if ($commentModule->hasChildren()) { |
|
67
|
|
|
$section->addChild($commentModule); |
|
|
|
|
|
|
68
|
|
|
$rootNavigationItem->addChild($section); |
|
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
$this->setNavigation(new Navigation($rootNavigationItem)); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* {@inheritdoc} |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getSecurityContexts() |
|
78
|
|
|
{ |
|
79
|
|
|
return [ |
|
80
|
|
|
'Sulu' => [ |
|
81
|
|
|
'Comment' => [ |
|
82
|
|
|
self::COMMENT_SECURITY_CONTEXT => [ |
|
83
|
|
|
PermissionTypes::VIEW, |
|
84
|
|
|
PermissionTypes::DELETE, |
|
85
|
|
|
PermissionTypes::LIVE, |
|
86
|
|
|
], |
|
87
|
|
|
self::THREAD_SECURITY_CONTEXT => [ |
|
88
|
|
|
PermissionTypes::VIEW, |
|
89
|
|
|
PermissionTypes::DELETE, |
|
90
|
|
|
PermissionTypes::EDIT, |
|
91
|
|
|
], |
|
92
|
|
|
], |
|
93
|
|
|
], |
|
94
|
|
|
]; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* {@inheritdoc} |
|
99
|
|
|
*/ |
|
100
|
|
|
public function getJsBundleName() |
|
101
|
|
|
{ |
|
102
|
|
|
return 'sulucomment'; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
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: