| @@ 315-330 (lines=16) @@ | ||
| 312 | { |
|
| 313 | foreach ($assignments as $assign) { |
|
| 314 | switch ($assign['type']) { |
|
| 315 | case 'user': |
|
| 316 | foreach ($assign['ids'] as $userId) { |
|
| 317 | $userId = $this->referenceResolver->resolveReference($userId); |
|
| 318 | ||
| 319 | $user = $userService->loadUser($userId); |
|
| 320 | ||
| 321 | if (!isset($assign['limitations'])) { |
|
| 322 | $roleService->assignRoleToUser($role, $user); |
|
| 323 | } else { |
|
| 324 | foreach ($assign['limitations'] as $limitation) { |
|
| 325 | $limitationObject = $this->createLimitation($roleService, $limitation); |
|
| 326 | $roleService->assignRoleToUser($role, $user, $limitationObject); |
|
| 327 | } |
|
| 328 | } |
|
| 329 | } |
|
| 330 | break; |
|
| 331 | case 'group': |
|
| 332 | foreach ($assign['ids'] as $groupId) { |
|
| 333 | $groupId = $this->referenceResolver->resolveReference($groupId); |
|
| @@ 331-352 (lines=22) @@ | ||
| 328 | } |
|
| 329 | } |
|
| 330 | break; |
|
| 331 | case 'group': |
|
| 332 | foreach ($assign['ids'] as $groupId) { |
|
| 333 | $groupId = $this->referenceResolver->resolveReference($groupId); |
|
| 334 | ||
| 335 | $group = $userService->loadUserGroup($groupId); |
|
| 336 | ||
| 337 | if (!isset($assign['limitations'])) { |
|
| 338 | // q: why are we swallowing exceptions here ? |
|
| 339 | //try { |
|
| 340 | $roleService->assignRoleToUserGroup($role, $group); |
|
| 341 | //} catch (InvalidArgumentException $e) {} |
|
| 342 | } else { |
|
| 343 | foreach ($assign['limitations'] as $limitation) { |
|
| 344 | $limitationObject = $this->createLimitation($roleService, $limitation); |
|
| 345 | // q: why are we swallowing exceptions here ? |
|
| 346 | //try { |
|
| 347 | $roleService->assignRoleToUserGroup($role, $group, $limitationObject); |
|
| 348 | //} catch (InvalidArgumentException $e) {} |
|
| 349 | } |
|
| 350 | } |
|
| 351 | } |
|
| 352 | break; |
|
| 353 | } |
|
| 354 | } |
|
| 355 | } |
|