| @@ 287-296 (lines=10) @@ | ||
| 284 | * @param string|Role $role |
|
| 285 | * @param string|int $userId |
|
| 286 | */ |
|
| 287 | protected function assign($role, $userId) |
|
| 288 | { |
|
| 289 | if (is_string($role)) { |
|
| 290 | $role = $this->findRole($role); |
|
| 291 | } |
|
| 292 | echo " > assigning $role->name to user $userId ..."; |
|
| 293 | $time = microtime(true); |
|
| 294 | $this->authManager->assign($role, $userId); |
|
| 295 | echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 296 | } |
|
| 297 | ||
| 298 | /** |
|
| 299 | * Updates role. |
|
| @@ 329-339 (lines=11) @@ | ||
| 326 | * |
|
| 327 | * @param string $name |
|
| 328 | */ |
|
| 329 | protected function removeRole($name) |
|
| 330 | { |
|
| 331 | $role = $this->authManager->getRole($name); |
|
| 332 | if (empty($role)) { |
|
| 333 | throw new InvalidParamException("Role '{$role}' does not exists"); |
|
| 334 | } |
|
| 335 | echo " > removing role $role->name ..."; |
|
| 336 | $time = microtime(true); |
|
| 337 | $this->authManager->remove($role); |
|
| 338 | echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 339 | } |
|
| 340 | ||
| 341 | /** |
|
| 342 | * Updates permission. |
|
| @@ 372-382 (lines=11) @@ | ||
| 369 | * |
|
| 370 | * @param string $name |
|
| 371 | */ |
|
| 372 | protected function removePermission($name) |
|
| 373 | { |
|
| 374 | $permission = $this->authManager->getPermission($name); |
|
| 375 | if (empty($permission)) { |
|
| 376 | throw new InvalidParamException("Permission '{$permission}' does not exists"); |
|
| 377 | } |
|
| 378 | echo " > removing permission $permission->name ..."; |
|
| 379 | $time = microtime(true); |
|
| 380 | $this->authManager->remove($permission); |
|
| 381 | echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 382 | } |
|
| 383 | ||
| 384 | /** |
|
| 385 | * Updates rule. |
|
| @@ 412-422 (lines=11) @@ | ||
| 409 | * |
|
| 410 | * @param string $ruleName |
|
| 411 | */ |
|
| 412 | protected function removeRule($ruleName) |
|
| 413 | { |
|
| 414 | $rule = $this->authManager->getRule($ruleName); |
|
| 415 | if (empty($rule)) { |
|
| 416 | throw new InvalidParamException("Rule '{$ruleName}' does not exists"); |
|
| 417 | } |
|
| 418 | echo " > removing rule $rule->name ..."; |
|
| 419 | $time = microtime(true); |
|
| 420 | $this->authManager->remove($rule); |
|
| 421 | echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; |
|
| 422 | } |
|
| 423 | } |
|
| 424 | ||