1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* |
5
|
|
|
* (c) Yaroslav Honcharuk <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Yarhon\RouteGuardBundle\Tests\Functional\Bundle\SensioSecurityBundle\Controller; |
12
|
|
|
|
13
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
14
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
15
|
|
|
use Symfony\Component\HttpFoundation\Request; |
16
|
|
|
use Symfony\Component\HttpFoundation\Response; |
17
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted; |
18
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Yaroslav Honcharuk <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class Controller extends AbstractController |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @Route("/public", name="public") |
27
|
|
|
*/ |
28
|
|
|
public function publicAction() |
29
|
|
|
{ |
30
|
|
|
return new Response(''); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @Route("/is_granted/user_role", name="is_granted_user_role") |
35
|
|
|
* @IsGranted("ROLE_USER", subject="argument") |
36
|
|
|
*/ |
37
|
|
|
public function isGrantedUserRoleAction($argument = 10) |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
return new Response(''); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @Route("/is_granted/admin_role", name="is_granted_admin_role") |
44
|
|
|
* @IsGranted("ROLE_ADMIN", subject="argument") |
45
|
|
|
*/ |
46
|
|
|
public function isGrantedAdminRoleAction($argument = 10) |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
return new Response(''); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @Route("/security/user_role", name="security_user_role") |
53
|
|
|
* @Security("is_granted('ROLE_USER')") |
54
|
|
|
*/ |
55
|
|
|
public function securityUserRoleAction() |
56
|
|
|
{ |
57
|
|
|
return new Response(''); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @Route("/security/admin_role", name="security_admin_role") |
62
|
|
|
* @Security("is_granted('ROLE_ADMIN')") |
63
|
|
|
*/ |
64
|
|
|
public function securityAdminRoleAction() |
65
|
|
|
{ |
66
|
|
|
return new Response(''); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @Route("/security/controller_argument/{argument}", name="security_controller_argument") |
71
|
|
|
* @Security("argument == 10") |
72
|
|
|
*/ |
73
|
|
|
public function securityControllerArgumentAction($argument) |
|
|
|
|
74
|
|
|
{ |
75
|
|
|
return new Response(''); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.