1 | <?php |
||
14 | class HierarchicalRole implements HierarchicalRoleInterface |
||
15 | { |
||
16 | /** |
||
17 | * @var int|null |
||
18 | * |
||
19 | * @ORM\Id |
||
20 | * @ORM\Column(type="integer") |
||
21 | * @ORM\GeneratedValue(strategy="AUTO") |
||
22 | */ |
||
23 | protected $id; |
||
24 | |||
25 | /** |
||
26 | * @var string|null |
||
27 | * |
||
28 | * @ORM\Column(type="string", length=48, unique=true) |
||
29 | */ |
||
30 | protected $name; |
||
31 | |||
32 | /** |
||
33 | * @var HierarchicalRoleInterface[]|\Doctrine\Common\Collections\Collection |
||
34 | * |
||
35 | * @ORM\ManyToMany(targetEntity="JhUser\Entity\HierarchicalRole") |
||
36 | * @ORM\JoinTable(name="role_role", |
||
37 | * joinColumns={@ORM\JoinColumn(name="src_role_id", referencedColumnName="id")}, |
||
38 | * inverseJoinColumns={@ORM\JoinColumn(name="target_role_id", referencedColumnName="id")} |
||
39 | * ) |
||
40 | */ |
||
41 | protected $children = []; |
||
42 | |||
43 | /** |
||
44 | * @var PermissionInterface[]|\Doctrine\Common\Collections\Collection |
||
45 | * |
||
46 | * @ORM\ManyToMany(targetEntity="JhUser\Entity\Permission", indexBy="name", fetch="EAGER") |
||
47 | * @ORM\JoinTable(name="role_permission", |
||
48 | * joinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")}, |
||
49 | * inverseJoinColumns={@ORM\JoinColumn(name="permission_id", referencedColumnName="id")} |
||
50 | * ) |
||
51 | */ |
||
52 | protected $permissions; |
||
53 | |||
54 | /** |
||
55 | * Init the Doctrine collection |
||
56 | */ |
||
57 | public function __construct() |
||
62 | |||
63 | /** |
||
64 | * Get the role identifier |
||
65 | * |
||
66 | * @return int |
||
67 | */ |
||
68 | public function getId() |
||
72 | |||
73 | /** |
||
74 | * Set the role name |
||
75 | * |
||
76 | * @param string $name |
||
77 | * @return void |
||
78 | */ |
||
79 | public function setName($name) |
||
83 | |||
84 | /** |
||
85 | * Get the role name |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | public function getName() |
||
93 | |||
94 | /** |
||
95 | * {@inheritDoc} |
||
96 | */ |
||
97 | public function addChild(HierarchicalRoleInterface $child) |
||
101 | |||
102 | /** |
||
103 | * {@inheritDoc} |
||
104 | */ |
||
105 | public function addPermission(Permission $permission) |
||
109 | |||
110 | /** |
||
111 | * {@inheritDoc} |
||
112 | */ |
||
113 | public function hasPermission($permission) |
||
120 | |||
121 | /** |
||
122 | * {@inheritDoc} |
||
123 | */ |
||
124 | public function getChildren() |
||
128 | |||
129 | /** |
||
130 | * {@inheritDoc} |
||
131 | */ |
||
132 | public function hasChildren() |
||
136 | } |
||
137 |