@@ -4,6 +4,5 @@ |
||
4 | 4 | |
5 | 5 | use Symfony\Component\HttpKernel\Bundle\Bundle; |
6 | 6 | |
7 | -class RibsAdminBundle extends Bundle |
|
8 | -{ |
|
7 | +class RibsAdminBundle extends Bundle { |
|
9 | 8 | } |
@@ -48,8 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | private $user; |
50 | 50 | |
51 | - public function __construct() |
|
52 | - { |
|
51 | + public function __construct() { |
|
53 | 52 | $this->isActive = true; |
54 | 53 | // may not be needed, see section on salt below |
55 | 54 | // $this->salt = md5(uniqid('', true)); |
@@ -58,96 +57,84 @@ discard block |
||
58 | 57 | /** |
59 | 58 | * @return mixed |
60 | 59 | */ |
61 | - public function getId() |
|
62 | - { |
|
60 | + public function getId() { |
|
63 | 61 | return $this->id; |
64 | 62 | } |
65 | 63 | |
66 | 64 | /** |
67 | 65 | * @param mixed $id |
68 | 66 | */ |
69 | - public function setId($id) |
|
70 | - { |
|
67 | + public function setId($id) { |
|
71 | 68 | $this->id = $id; |
72 | 69 | } |
73 | 70 | |
74 | 71 | /** |
75 | 72 | * @return mixed |
76 | 73 | */ |
77 | - public function getEmail() |
|
78 | - { |
|
74 | + public function getEmail() { |
|
79 | 75 | return $this->email; |
80 | 76 | } |
81 | 77 | |
82 | 78 | /** |
83 | 79 | * @param mixed $email |
84 | 80 | */ |
85 | - public function setEmail($email) |
|
86 | - { |
|
81 | + public function setEmail($email) { |
|
87 | 82 | $this->email = $email; |
88 | 83 | } |
89 | 84 | |
90 | 85 | /** |
91 | 86 | * @return mixed |
92 | 87 | */ |
93 | - public function getPassword() |
|
94 | - { |
|
88 | + public function getPassword() { |
|
95 | 89 | return $this->password; |
96 | 90 | } |
97 | 91 | |
98 | 92 | /** |
99 | 93 | * @param mixed $password |
100 | 94 | */ |
101 | - public function setPassword($password) |
|
102 | - { |
|
95 | + public function setPassword($password) { |
|
103 | 96 | $this->password = $password; |
104 | 97 | } |
105 | 98 | |
106 | 99 | /** |
107 | 100 | * @return mixed |
108 | 101 | */ |
109 | - public function getUsername() |
|
110 | - { |
|
102 | + public function getUsername() { |
|
111 | 103 | return $this->username; |
112 | 104 | } |
113 | 105 | |
114 | 106 | /** |
115 | 107 | * @param mixed $username |
116 | 108 | */ |
117 | - public function setUsername($username) |
|
118 | - { |
|
109 | + public function setUsername($username) { |
|
119 | 110 | $this->username = $username; |
120 | 111 | } |
121 | 112 | |
122 | 113 | /** |
123 | 114 | * @return mixed |
124 | 115 | */ |
125 | - public function getisActive() |
|
126 | - { |
|
116 | + public function getisActive() { |
|
127 | 117 | return $this->isActive; |
128 | 118 | } |
129 | 119 | |
130 | 120 | /** |
131 | 121 | * @param mixed $isActive |
132 | 122 | */ |
133 | - public function setIsActive($isActive) |
|
134 | - { |
|
123 | + public function setIsActive($isActive) { |
|
135 | 124 | $this->isActive = $isActive; |
136 | 125 | } |
137 | 126 | |
138 | 127 | /** |
139 | 128 | * @return User |
140 | 129 | */ |
141 | - public function getUser() |
|
142 | - { |
|
130 | + public function getUser() { |
|
143 | 131 | return $this->user; |
144 | 132 | } |
145 | 133 | |
146 | 134 | /** |
147 | 135 | * @param User $user |
148 | 136 | */ |
149 | - public function setUser($user) |
|
150 | - { |
|
137 | + public function setUser($user) { |
|
151 | 138 | $this->user = $user; |
152 | 139 | } |
153 | 140 | |
@@ -167,8 +154,7 @@ discard block |
||
167 | 154 | * |
168 | 155 | * @return (Role|string)[] The user roles |
169 | 156 | */ |
170 | - public function getRoles() |
|
171 | - { |
|
157 | + public function getRoles() { |
|
172 | 158 | return ['ROLE_ADMIN']; |
173 | 159 | } |
174 | 160 | |
@@ -179,8 +165,7 @@ discard block |
||
179 | 165 | * |
180 | 166 | * @return string|null The salt |
181 | 167 | */ |
182 | - public function getSalt() |
|
183 | - { |
|
168 | + public function getSalt() { |
|
184 | 169 | // you *may* need a real salt depending on your encoder |
185 | 170 | // see section on salt below |
186 | 171 | return null; |
@@ -192,8 +177,7 @@ discard block |
||
192 | 177 | * This is important if, at any given point, sensitive information like |
193 | 178 | * the plain-text password is stored on this object. |
194 | 179 | */ |
195 | - public function eraseCredentials() |
|
196 | - { |
|
180 | + public function eraseCredentials() { |
|
197 | 181 | } |
198 | 182 | |
199 | 183 | /** |
@@ -202,8 +186,7 @@ discard block |
||
202 | 186 | * @return string the string representation of the object or null |
203 | 187 | * @since 5.1.0 |
204 | 188 | */ |
205 | - public function serialize() |
|
206 | - { |
|
189 | + public function serialize() { |
|
207 | 190 | return serialize([ |
208 | 191 | $this->id, |
209 | 192 | $this->username, |
@@ -222,8 +205,7 @@ discard block |
||
222 | 205 | * @return void |
223 | 206 | * @since 5.1.0 |
224 | 207 | */ |
225 | - public function unserialize($serialized) |
|
226 | - { |
|
208 | + public function unserialize($serialized) { |
|
227 | 209 | list ( |
228 | 210 | $this->id, |
229 | 211 | $this->username, |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | * @ORM\Entity(repositoryClass="Ribs\RibsAdminBundle\Repository\AccessRightRepository") |
15 | 15 | * @ORM\EntityListeners({"Ribs\RibsAdminBundle\EventListener\GuidAwareListener"}) |
16 | 16 | */ |
17 | -class AccessRight |
|
18 | -{ |
|
17 | +class AccessRight { |
|
19 | 18 | /** |
20 | 19 | * @var integer |
21 | 20 | * |
@@ -72,112 +71,98 @@ discard block |
||
72 | 71 | /** |
73 | 72 | * AccessRight constructor. |
74 | 73 | */ |
75 | - public function __construct() |
|
76 | - { |
|
74 | + public function __construct() { |
|
77 | 75 | $this->users = new ArrayCollection(); |
78 | 76 | } |
79 | 77 | |
80 | 78 | /** |
81 | 79 | * @return int |
82 | 80 | */ |
83 | - public function getId() |
|
84 | - { |
|
81 | + public function getId() { |
|
85 | 82 | return $this->id; |
86 | 83 | } |
87 | 84 | |
88 | 85 | /** |
89 | 86 | * @param int $id |
90 | 87 | */ |
91 | - public function setId(int $id) |
|
92 | - { |
|
88 | + public function setId(int $id) { |
|
93 | 89 | $this->id = $id; |
94 | 90 | } |
95 | 91 | |
96 | 92 | /** |
97 | 93 | * @return string |
98 | 94 | */ |
99 | - public function getGuid() |
|
100 | - { |
|
95 | + public function getGuid() { |
|
101 | 96 | return $this->guid; |
102 | 97 | } |
103 | 98 | |
104 | 99 | /** |
105 | 100 | * @param string $guid |
106 | 101 | */ |
107 | - public function setGuid(string $guid) |
|
108 | - { |
|
102 | + public function setGuid(string $guid) { |
|
109 | 103 | $this->guid = $guid; |
110 | 104 | } |
111 | 105 | |
112 | 106 | /** |
113 | 107 | * @return string |
114 | 108 | */ |
115 | - public function getName() |
|
116 | - { |
|
109 | + public function getName() { |
|
117 | 110 | return $this->name; |
118 | 111 | } |
119 | 112 | |
120 | 113 | /** |
121 | 114 | * @param string $name |
122 | 115 | */ |
123 | - public function setName(string $name) |
|
124 | - { |
|
116 | + public function setName(string $name) { |
|
125 | 117 | $this->name = $name; |
126 | 118 | } |
127 | 119 | |
128 | 120 | /** |
129 | 121 | * @return string |
130 | 122 | */ |
131 | - public function getAccessRights() |
|
132 | - { |
|
123 | + public function getAccessRights() { |
|
133 | 124 | return $this->accessRights; |
134 | 125 | } |
135 | 126 | |
136 | 127 | /** |
137 | 128 | * @param string $accessRights |
138 | 129 | */ |
139 | - public function setAccessRights(string $accessRights) |
|
140 | - { |
|
130 | + public function setAccessRights(string $accessRights) { |
|
141 | 131 | $this->accessRights = $accessRights; |
142 | 132 | } |
143 | 133 | |
144 | 134 | /** |
145 | 135 | * @return \DateTime |
146 | 136 | */ |
147 | - public function getCreationDate() |
|
148 | - { |
|
137 | + public function getCreationDate() { |
|
149 | 138 | return $this->creationDate; |
150 | 139 | } |
151 | 140 | |
152 | 141 | /** |
153 | 142 | * @param \DateTime $creationDate |
154 | 143 | */ |
155 | - public function setCreationDate(\DateTime $creationDate) |
|
156 | - { |
|
144 | + public function setCreationDate(\DateTime $creationDate) { |
|
157 | 145 | $this->creationDate = $creationDate; |
158 | 146 | } |
159 | 147 | |
160 | 148 | /** |
161 | 149 | * @return \DateTime |
162 | 150 | */ |
163 | - public function getUpdateDate() |
|
164 | - { |
|
151 | + public function getUpdateDate() { |
|
165 | 152 | return $this->updateDate; |
166 | 153 | } |
167 | 154 | |
168 | 155 | /** |
169 | 156 | * @param \DateTime $updateDate |
170 | 157 | */ |
171 | - public function setUpdateDate(\DateTime $updateDate) |
|
172 | - { |
|
158 | + public function setUpdateDate(\DateTime $updateDate) { |
|
173 | 159 | $this->updateDate = $updateDate; |
174 | 160 | } |
175 | 161 | |
176 | 162 | /** |
177 | 163 | * @return ArrayCollection |
178 | 164 | */ |
179 | - public function getUsers() |
|
180 | - { |
|
165 | + public function getUsers() { |
|
181 | 166 | return $this->users; |
182 | 167 | } |
183 | 168 | |
@@ -185,8 +170,7 @@ discard block |
||
185 | 170 | * @param User $user |
186 | 171 | * @return $this |
187 | 172 | */ |
188 | - public function addUser(User $user) |
|
189 | - { |
|
173 | + public function addUser(User $user) { |
|
190 | 174 | $this->users[] = $user; |
191 | 175 | |
192 | 176 | return $this; |
@@ -195,8 +179,7 @@ discard block |
||
195 | 179 | /** |
196 | 180 | * @param User $user |
197 | 181 | */ |
198 | - public function removeUser(User $user) |
|
199 | - { |
|
182 | + public function removeUser(User $user) { |
|
200 | 183 | $this->users->removeElement($user); |
201 | 184 | } |
202 | 185 | } |
203 | 186 | \ No newline at end of file |
@@ -11,10 +11,8 @@ discard block |
||
11 | 11 | use Symfony\Component\Form\Extension\Core\Type\RepeatedType; |
12 | 12 | use Symfony\Component\Form\Extension\Core\Type\PasswordType; |
13 | 13 | |
14 | -class Registration extends AbstractType |
|
15 | -{ |
|
16 | - public function buildForm(FormBuilderInterface $builder, array $options) |
|
17 | - { |
|
14 | +class Registration extends AbstractType { |
|
15 | + public function buildForm(FormBuilderInterface $builder, array $options) { |
|
18 | 16 | $builder |
19 | 17 | ->add('email', EmailType::class) |
20 | 18 | ->add('username', TextType::class) |
@@ -25,8 +23,7 @@ discard block |
||
25 | 23 | ]); |
26 | 24 | } |
27 | 25 | |
28 | - public function configureOptions(OptionsResolver $resolver) |
|
29 | - { |
|
26 | + public function configureOptions(OptionsResolver $resolver) { |
|
30 | 27 | $resolver->setDefaults([ |
31 | 28 | 'data_class' => Account::class, |
32 | 29 | ]); |
@@ -5,8 +5,7 @@ |
||
5 | 5 | use Doctrine\ORM\EntityRepository; |
6 | 6 | use Ribs\RibsAdminBundle\Entity\User; |
7 | 7 | |
8 | -class AccountRepository extends EntityRepository |
|
9 | -{ |
|
8 | +class AccountRepository extends EntityRepository { |
|
10 | 9 | /** |
11 | 10 | * @param User $current_account |
12 | 11 | * @param bool $archived |
@@ -5,14 +5,12 @@ |
||
5 | 5 | use Doctrine\ORM\EntityRepository; |
6 | 6 | use Ribs\RibsAdminBundle\Entity\AccessRight; |
7 | 7 | |
8 | -class AccessRightRepository extends EntityRepository |
|
9 | -{ |
|
8 | +class AccessRightRepository extends EntityRepository { |
|
10 | 9 | /** |
11 | 10 | * @param AccessRight $access_right |
12 | 11 | * function that delete all user which are in a list of rights |
13 | 12 | */ |
14 | - public function deleteAllUsersList(AccessRight $access_right) |
|
15 | - { |
|
13 | + public function deleteAllUsersList(AccessRight $access_right) { |
|
16 | 14 | $query = $this->getEntityManager()->getConnection()->prepare("UPDATE user SET id_access_right = NULL WHERE |
17 | 15 | id_access_right = :id_access_right |
18 | 16 | "); |
@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | use Symfony\Component\HttpFoundation\Response; |
10 | 10 | use Symfony\Component\Routing\Annotation\Route; |
11 | 11 | |
12 | -class AccessRightsController extends Controller |
|
13 | -{ |
|
12 | +class AccessRightsController extends Controller { |
|
14 | 13 | //---------------------------------------------- VIEWS METHODS ---------------------------------------------------------// |
15 | 14 | /** |
16 | 15 | * @Route("/access-rights-management/", name="ribsadmin_access_rights") |
@@ -40,7 +39,8 @@ discard block |
||
40 | 39 | |
41 | 40 | if ($guid === null) { |
42 | 41 | $access_right = new AccessRight(); |
43 | - } else { |
|
42 | + } |
|
43 | + else { |
|
44 | 44 | $access_right = $em->getRepository("RibsAdminBundle:AccessRight")->findOneBy(["guid" => $guid]); |
45 | 45 | $list_rights_user = explode(",", $access_right->getAccessRights()); |
46 | 46 | } |
@@ -75,7 +75,8 @@ discard block |
||
75 | 75 | |
76 | 76 | if ($request->get("right") === null) { |
77 | 77 | $rights = ""; |
78 | - } else { |
|
78 | + } |
|
79 | + else { |
|
79 | 80 | $rights = implode(",", $request->get("right")); |
80 | 81 | } |
81 | 82 | |
@@ -116,7 +117,8 @@ discard block |
||
116 | 117 | $em->flush(); |
117 | 118 | |
118 | 119 | $this->addFlash("success-flash", "The right list was deleted"); |
119 | - } else { |
|
120 | + } |
|
121 | + else { |
|
120 | 122 | $this->addFlash("error-flash", "The right list wasn't found"); |
121 | 123 | } |
122 | 124 |
@@ -8,16 +8,14 @@ |
||
8 | 8 | use Symfony\Component\HttpFoundation\RedirectResponse; |
9 | 9 | use Symfony\Component\Routing\Annotation\Route; |
10 | 10 | |
11 | -class LoginController extends Controller |
|
12 | -{ |
|
11 | +class LoginController extends Controller { |
|
13 | 12 | /** |
14 | 13 | * @Route("/login/", name="ribsadmin_login") |
15 | 14 | * @param Request $request |
16 | 15 | * |
17 | 16 | * @return Response |
18 | 17 | */ |
19 | - public function loginAction() |
|
20 | - { |
|
18 | + public function loginAction() { |
|
21 | 19 | $csrf_token = $this->has('security.csrf.token_manager') |
22 | 20 | ? $this->get('security.csrf.token_manager')->getToken('authenticate')->getValue() |
23 | 21 | : null; |
@@ -8,13 +8,11 @@ |
||
8 | 8 | use Symfony\Component\HttpFoundation\Request; |
9 | 9 | use Symfony\Component\Routing\Annotation\Route; |
10 | 10 | |
11 | -class RegistrationController extends Controller |
|
12 | -{ |
|
11 | +class RegistrationController extends Controller { |
|
13 | 12 | /** |
14 | 13 | * @Route("/register/", name="ribsadmin_register") |
15 | 14 | */ |
16 | - public function registerAction(Request $request) |
|
17 | - { |
|
15 | + public function registerAction(Request $request) { |
|
18 | 16 | // 1) build the form |
19 | 17 | $passwordEncoder = $this->get("security.password_encoder"); |
20 | 18 | $user = new Account(); |