Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like RoleService often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use RoleService, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 45 | class RoleService implements APIRoleService, Sessionable |
||
| 46 | { |
||
| 47 | /** |
||
| 48 | * @var \eZ\Publish\Core\REST\Client\UserService |
||
| 49 | */ |
||
| 50 | private $userService; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var \eZ\Publish\Core\REST\Client\HttpClient |
||
| 54 | */ |
||
| 55 | private $client; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var \eZ\Publish\Core\REST\Common\Input\Dispatcher |
||
| 59 | */ |
||
| 60 | private $inputDispatcher; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @var \eZ\Publish\Core\REST\Common\Output\Visitor |
||
| 64 | */ |
||
| 65 | private $outputVisitor; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @var \eZ\Publish\Core\REST\Common\RequestParser |
||
| 69 | */ |
||
| 70 | private $requestParser; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param \eZ\Publish\Core\REST\Client\UserService $userService |
||
| 74 | * @param \eZ\Publish\Core\REST\Client\HttpClient $client |
||
| 75 | * @param \eZ\Publish\Core\REST\Common\Input\Dispatcher $inputDispatcher |
||
| 76 | * @param \eZ\Publish\Core\REST\Common\Output\Visitor $outputVisitor |
||
| 77 | * @param \eZ\Publish\Core\REST\Common\RequestParser $requestParser |
||
| 78 | */ |
||
| 79 | View Code Duplication | public function __construct(UserService $userService, HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser) |
|
| 87 | |||
| 88 | /** |
||
| 89 | * Set session ID. |
||
| 90 | * |
||
| 91 | * Only for testing |
||
| 92 | * |
||
| 93 | * @param mixed $id |
||
| 94 | * |
||
| 95 | * @private |
||
| 96 | */ |
||
| 97 | public function setSession($id) |
||
| 103 | |||
| 104 | /** |
||
| 105 | * Creates a new RoleDraft for existing Role. |
||
| 106 | * |
||
| 107 | * @since 6.0 |
||
| 108 | * |
||
| 109 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a role |
||
| 110 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the Role already has a Role Draft that will need to be removed first |
||
| 111 | * @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a policy limitation in the $roleCreateStruct is not valid |
||
| 112 | * |
||
| 113 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
||
| 114 | * |
||
| 115 | * @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
||
| 116 | */ |
||
| 117 | public function createRoleDraft(APIRole $role) |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Loads a RoleDraft for the given id. |
||
| 169 | * |
||
| 170 | * @since 6.0 |
||
| 171 | * |
||
| 172 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read this role |
||
| 173 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a role with the given id was not found |
||
| 174 | * |
||
| 175 | * @param mixed $id |
||
| 176 | * |
||
| 177 | * @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
||
| 178 | */ |
||
| 179 | View Code Duplication | public function loadRoleDraft($id) |
|
| 209 | |||
| 210 | /** |
||
| 211 | * Loads a RoleDraft by the ID of the role it was created from. |
||
| 212 | * |
||
| 213 | * @param mixed $roleId ID of the role the draft was created from. |
||
| 214 | * |
||
| 215 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read this role |
||
| 216 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a RoleDraft with the given id was not found |
||
| 217 | * |
||
| 218 | * @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
||
| 219 | */ |
||
| 220 | public function loadRoleDraftByRoleId($roleId) |
||
| 224 | |||
| 225 | /** |
||
| 226 | * Updates the properties of a role draft. |
||
| 227 | * |
||
| 228 | * @since 6.0 |
||
| 229 | * |
||
| 230 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update a role |
||
| 231 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the identifier of the role already exists |
||
| 232 | * |
||
| 233 | * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
||
| 234 | * @param \eZ\Publish\API\Repository\Values\User\RoleUpdateStruct $roleUpdateStruct |
||
| 235 | * |
||
| 236 | * @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
||
| 237 | */ |
||
| 238 | public function updateRoleDraft(APIRoleDraft $roleDraft, RoleUpdateStruct $roleUpdateStruct) |
||
| 252 | |||
| 253 | /** |
||
| 254 | * Adds a new policy to the role draft. |
||
| 255 | * |
||
| 256 | * @since 6.0 |
||
| 257 | * |
||
| 258 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to add a policy |
||
| 259 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if limitation of the same type is repeated in policy create |
||
| 260 | * struct or if limitation is not allowed on module/function |
||
| 261 | * @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a limitation in the $policyCreateStruct is not valid |
||
| 262 | * |
||
| 263 | * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
||
| 264 | * @param \eZ\Publish\API\Repository\Values\User\PolicyCreateStruct $policyCreateStruct |
||
| 265 | * |
||
| 266 | * @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
||
| 267 | */ |
||
| 268 | View Code Duplication | public function addPolicyByRoleDraft(APIRoleDraft $roleDraft, APIPolicyCreateStruct $policyCreateStruct) |
|
| 303 | |||
| 304 | /** |
||
| 305 | * Removes a policy from a role draft. |
||
| 306 | * |
||
| 307 | * @since 6.0 |
||
| 308 | * |
||
| 309 | * |
||
| 310 | * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
||
| 311 | * @param PolicyDraft $policyDraft the policy to remove from the role |
||
| 312 | * @return APIRoleDraft if the authenticated user is not allowed to remove a policy |
||
| 313 | */ |
||
| 314 | View Code Duplication | public function removePolicyByRoleDraft(APIRoleDraft $roleDraft, PolicyDraft $policyDraft) |
|
| 341 | |||
| 342 | /** |
||
| 343 | * Updates the limitations of a policy. The module and function cannot be changed and |
||
| 344 | * the limitations are replaced by the ones in $roleUpdateStruct. |
||
| 345 | * |
||
| 346 | * @since 6.0 |
||
| 347 | * |
||
| 348 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update a policy |
||
| 349 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if limitation of the same type is repeated in policy update |
||
| 350 | * struct or if limitation is not allowed on module/function |
||
| 351 | * @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a limitation in the $policyUpdateStruct is not valid |
||
| 352 | * |
||
| 353 | * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
||
| 354 | * @param \eZ\Publish\API\Repository\Values\User\PolicyDraft $policy |
||
| 355 | * @param \eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct $policyUpdateStruct |
||
| 356 | * |
||
| 357 | * @return \eZ\Publish\API\Repository\Values\User\PolicyDraft |
||
| 358 | */ |
||
| 359 | View Code Duplication | public function updatePolicyByRoleDraft(APIRoleDraft $roleDraft, PolicyDraft $policy, APIPolicyUpdateStruct $policyUpdateStruct) |
|
| 380 | |||
| 381 | /** |
||
| 382 | * Deletes the given role. |
||
| 383 | * |
||
| 384 | * @since 6.0 |
||
| 385 | * |
||
| 386 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to delete this role |
||
| 387 | * |
||
| 388 | * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
||
| 389 | */ |
||
| 390 | View Code Duplication | public function deleteRoleDraft(APIRoleDraft $roleDraft) |
|
| 408 | |||
| 409 | /** |
||
| 410 | * Publishes a given Role draft. |
||
| 411 | * |
||
| 412 | * @since 6.0 |
||
| 413 | * |
||
| 414 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to delete this role |
||
| 415 | * |
||
| 416 | * @param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft |
||
| 417 | */ |
||
| 418 | public function publishRoleDraft(APIRoleDraft $roleDraft) |
||
| 422 | |||
| 423 | /** |
||
| 424 | * Creates a new RoleDraft. |
||
| 425 | * |
||
| 426 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to create a role |
||
| 427 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the name of the role already exists or if limitation of the |
||
| 428 | * same type is repeated in the policy create struct or if |
||
| 429 | * limitation is not allowed on module/function |
||
| 430 | * @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a policy limitation in the $roleCreateStruct is not valid |
||
| 431 | * |
||
| 432 | * @param \eZ\Publish\API\Repository\Values\User\RoleCreateStruct $roleCreateStruct |
||
| 433 | * |
||
| 434 | * @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
||
| 435 | */ |
||
| 436 | public function createRole(APIRoleCreateStruct $roleCreateStruct) |
||
| 483 | |||
| 484 | /** |
||
| 485 | * Updates the name of the role. |
||
| 486 | * |
||
| 487 | * @deprecated since 6.0, use {@see updateRoleDraft} |
||
| 488 | * |
||
| 489 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update a role |
||
| 490 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the name of the role already exists |
||
| 491 | * |
||
| 492 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
||
| 493 | * @param \eZ\Publish\API\Repository\Values\User\RoleUpdateStruct $roleUpdateStruct |
||
| 494 | * |
||
| 495 | * @return \eZ\Publish\API\Repository\Values\User\Role |
||
| 496 | */ |
||
| 497 | public function updateRole(APIRole $role, RoleUpdateStruct $roleUpdateStruct) |
||
| 511 | |||
| 512 | /** |
||
| 513 | * Adds a new policy to the role. |
||
| 514 | * |
||
| 515 | * @deprecated since 6.0, use {@see addPolicyByRoleDraft} |
||
| 516 | * |
||
| 517 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to add a policy |
||
| 518 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if limitation of the same type is repeated in policy create |
||
| 519 | * struct or if limitation is not allowed on module/function |
||
| 520 | * @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a limitation in the $policyCreateStruct is not valid |
||
| 521 | * |
||
| 522 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
||
| 523 | * @param \eZ\Publish\API\Repository\Values\User\PolicyCreateStruct $policyCreateStruct |
||
| 524 | * |
||
| 525 | * @return \eZ\Publish\API\Repository\Values\User\Role |
||
| 526 | */ |
||
| 527 | View Code Duplication | public function addPolicy(APIRole $role, APIPolicyCreateStruct $policyCreateStruct) |
|
| 562 | |||
| 563 | /** |
||
| 564 | * Removes a policy from the role. |
||
| 565 | * |
||
| 566 | * @deprecated since 5.3, use {@link removePolicyByRoleDraft()} instead. |
||
| 567 | * |
||
| 568 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove a policy |
||
| 569 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if policy does not belong to the given role |
||
| 570 | * |
||
| 571 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
||
| 572 | * @param \eZ\Publish\API\Repository\Values\User\Policy $policy the policy to remove from the role |
||
| 573 | * |
||
| 574 | * @return \eZ\Publish\API\Repository\Values\User\Role the updated role |
||
| 575 | */ |
||
| 576 | View Code Duplication | public function removePolicy(APIRole $role, APIPolicy $policy) |
|
| 603 | |||
| 604 | /** |
||
| 605 | * Deletes a policy. |
||
| 606 | * |
||
| 607 | * @deprecated since 6.0, use {@link removePolicyByRoleDraft()} instead. |
||
| 608 | * |
||
| 609 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove a policy |
||
| 610 | * |
||
| 611 | * @param \eZ\Publish\API\Repository\Values\User\Policy $policy the policy to delete |
||
| 612 | */ |
||
| 613 | public function deletePolicy(APIPolicy $policy) |
||
| 617 | |||
| 618 | /** |
||
| 619 | * Updates the limitations of a policy. The module and function cannot be changed and |
||
| 620 | * the limitations are replaced by the ones in $roleUpdateStruct. |
||
| 621 | * |
||
| 622 | * @deprecated since 6.0, use {@link updatePolicyByRoleDraft()} instead. |
||
| 623 | * |
||
| 624 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to update a policy |
||
| 625 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if limitation of the same type is repeated in policy update |
||
| 626 | * struct or if limitation is not allowed on module/function |
||
| 627 | * @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if a limitation in the $policyUpdateStruct is not valid |
||
| 628 | * |
||
| 629 | * @param \eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct $policyUpdateStruct |
||
| 630 | * @param \eZ\Publish\API\Repository\Values\User\Policy $policy |
||
| 631 | * |
||
| 632 | * @return \eZ\Publish\API\Repository\Values\User\Policy |
||
| 633 | */ |
||
| 634 | View Code Duplication | public function updatePolicy(APIPolicy $policy, APIPolicyUpdateStruct $policyUpdateStruct) |
|
| 655 | |||
| 656 | /** |
||
| 657 | * Loads a role for the given id. |
||
| 658 | * |
||
| 659 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read this role |
||
| 660 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a role with the given name was not found |
||
| 661 | * |
||
| 662 | * @param mixed $id |
||
| 663 | * |
||
| 664 | * @return \eZ\Publish\API\Repository\Values\User\Role |
||
| 665 | */ |
||
| 666 | View Code Duplication | public function loadRole($id) |
|
| 696 | |||
| 697 | /** |
||
| 698 | * Loads a role for the given name. |
||
| 699 | * |
||
| 700 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read this role |
||
| 701 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a role with the given name was not found |
||
| 702 | * |
||
| 703 | * @param string $name |
||
| 704 | * |
||
| 705 | * @return \eZ\Publish\API\Repository\Values\User\Role |
||
| 706 | */ |
||
| 707 | View Code Duplication | public function loadRoleByIdentifier($name) |
|
| 721 | |||
| 722 | /** |
||
| 723 | * Loads all roles. |
||
| 724 | * |
||
| 725 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read the roles |
||
| 726 | * |
||
| 727 | * @return \eZ\Publish\API\Repository\Values\User\Role[] |
||
| 728 | */ |
||
| 729 | public function loadRoles() |
||
| 741 | |||
| 742 | /** |
||
| 743 | * Deletes the given role. |
||
| 744 | * |
||
| 745 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to delete this role |
||
| 746 | * |
||
| 747 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
||
| 748 | */ |
||
| 749 | View Code Duplication | public function deleteRole(APIRole $role) |
|
| 767 | |||
| 768 | /** |
||
| 769 | * Loads all policies from roles which are assigned to a user or to user groups to which the user belongs. |
||
| 770 | * |
||
| 771 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a user with the given id was not found |
||
| 772 | * |
||
| 773 | * @param mixed $userId |
||
| 774 | * |
||
| 775 | * @return \eZ\Publish\API\Repository\Values\User\Policy[] |
||
| 776 | */ |
||
| 777 | View Code Duplication | public function loadPoliciesByUserId($userId) |
|
| 790 | |||
| 791 | /** |
||
| 792 | * Assigns a role to the given user group. |
||
| 793 | * |
||
| 794 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to assign a role |
||
| 795 | * @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if $roleLimitation is not valid |
||
| 796 | * |
||
| 797 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
||
| 798 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
||
| 799 | * @param \eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $roleLimitation an optional role limitation (which is either a subtree limitation or section limitation) |
||
| 800 | */ |
||
| 801 | View Code Duplication | public function assignRoleToUserGroup(APIRole $role, UserGroup $userGroup, RoleLimitation $roleLimitation = null) |
|
| 821 | |||
| 822 | /** |
||
| 823 | * removes a role from the given user group. |
||
| 824 | * |
||
| 825 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove a role |
||
| 826 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the role is not assigned to the given user group |
||
| 827 | * |
||
| 828 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
||
| 829 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
||
| 830 | */ |
||
| 831 | View Code Duplication | public function unassignRoleFromUserGroup(APIRole $role, UserGroup $userGroup) |
|
| 855 | |||
| 856 | /** |
||
| 857 | * Assigns a role to the given user. |
||
| 858 | * |
||
| 859 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to assign a role |
||
| 860 | * @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if $roleLimitation is not valid |
||
| 861 | * |
||
| 862 | * @todo add limitations |
||
| 863 | * |
||
| 864 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
||
| 865 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
| 866 | * @param \eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $roleLimitation an optional role limitation (which is either a subtree limitation or section limitation) |
||
| 867 | */ |
||
| 868 | View Code Duplication | public function assignRoleToUser(APIRole $role, User $user, RoleLimitation $roleLimitation = null) |
|
| 888 | |||
| 889 | /** |
||
| 890 | * removes a role from the given user. |
||
| 891 | * |
||
| 892 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove a role |
||
| 893 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If the role is not assigned to the user |
||
| 894 | * |
||
| 895 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
||
| 896 | * @param \eZ\Publish\API\Repository\Values\User\User $user |
||
| 897 | */ |
||
| 898 | View Code Duplication | public function unassignRoleFromUser(APIRole $role, User $user) |
|
| 922 | |||
| 923 | /** |
||
| 924 | * Removes the given role assignment. |
||
| 925 | * |
||
| 926 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to remove a role assignment |
||
| 927 | * |
||
| 928 | * @param \eZ\Publish\API\Repository\Values\User\RoleAssignment $roleAssignment |
||
| 929 | */ |
||
| 930 | public function removeRoleAssignment(APIRoleAssignment $roleAssignment) |
||
| 934 | |||
| 935 | /** |
||
| 936 | * Loads a user assignment for the given id. |
||
| 937 | * |
||
| 938 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read this role |
||
| 939 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the role assignment was not found |
||
| 940 | * |
||
| 941 | * @param mixed $roleAssignmentId |
||
| 942 | * |
||
| 943 | * @return \eZ\Publish\API\Repository\Values\User\RoleAssignment |
||
| 944 | */ |
||
| 945 | public function loadRoleAssignment($roleAssignmentId) |
||
| 949 | |||
| 950 | /** |
||
| 951 | * Returns the assigned user and user groups to this role. |
||
| 952 | * |
||
| 953 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read a role |
||
| 954 | * |
||
| 955 | * @param \eZ\Publish\API\Repository\Values\User\Role $role |
||
| 956 | * |
||
| 957 | * @return \eZ\Publish\API\Repository\Values\User\RoleAssignment[] |
||
| 958 | */ |
||
| 959 | public function getRoleAssignments(APIRole $role) |
||
| 963 | |||
| 964 | /** |
||
| 965 | * @see \eZ\Publish\API\Repository\RoleService::getRoleAssignmentsForUser() |
||
| 966 | */ |
||
| 967 | View Code Duplication | public function getRoleAssignmentsForUser(User $user, $inherited = false) |
|
| 992 | |||
| 993 | /** |
||
| 994 | * Returns the roles assigned to the given user group. |
||
| 995 | * |
||
| 996 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read a user group |
||
| 997 | * |
||
| 998 | * @param \eZ\Publish\API\Repository\Values\User\UserGroup $userGroup |
||
| 999 | * |
||
| 1000 | * @return \eZ\Publish\API\Repository\Values\User\UserGroupRoleAssignment[] |
||
| 1001 | */ |
||
| 1002 | View Code Duplication | public function getRoleAssignmentsForUserGroup(UserGroup $userGroup) |
|
| 1027 | |||
| 1028 | /** |
||
| 1029 | * Instantiates a role create class. |
||
| 1030 | * |
||
| 1031 | * @param string $name |
||
| 1032 | * |
||
| 1033 | * @return \eZ\Publish\API\Repository\Values\User\RoleCreateStruct |
||
| 1034 | */ |
||
| 1035 | public function newRoleCreateStruct($name) |
||
| 1039 | |||
| 1040 | /** |
||
| 1041 | * Instantiates a policy create class. |
||
| 1042 | * |
||
| 1043 | * @param string $module |
||
| 1044 | * @param string $function |
||
| 1045 | * |
||
| 1046 | * @return \eZ\Publish\API\Repository\Values\User\PolicyCreateStruct |
||
| 1047 | */ |
||
| 1048 | public function newPolicyCreateStruct($module, $function) |
||
| 1052 | |||
| 1053 | /** |
||
| 1054 | * Instantiates a policy update class. |
||
| 1055 | * |
||
| 1056 | * @return \eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct |
||
| 1057 | */ |
||
| 1058 | public function newPolicyUpdateStruct() |
||
| 1062 | |||
| 1063 | /** |
||
| 1064 | * Instantiates a policy update class. |
||
| 1065 | * |
||
| 1066 | * @return \eZ\Publish\API\Repository\Values\User\RoleUpdateStruct |
||
| 1067 | */ |
||
| 1068 | public function newRoleUpdateStruct() |
||
| 1072 | |||
| 1073 | /** |
||
| 1074 | * Returns the LimitationType registered with the given identifier. |
||
| 1075 | * |
||
| 1076 | * @param string $identifier |
||
| 1077 | * |
||
| 1078 | * @return \eZ\Publish\SPI\Limitation\Type |
||
| 1079 | * |
||
| 1080 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if there is no LimitationType with $identifier |
||
| 1081 | */ |
||
| 1082 | public function getLimitationType($identifier) |
||
| 1086 | |||
| 1087 | /** |
||
| 1088 | * Returns the LimitationType's assigned to a given module/function. |
||
| 1089 | * |
||
| 1090 | * Typically used for: |
||
| 1091 | * - Internal validation limitation value use on Policies |
||
| 1092 | * - Role admin gui for editing policy limitations incl list limitation options via valueSchema() |
||
| 1093 | * |
||
| 1094 | * @param string $module Legacy name of "controller", it's a unique identifier like "content" |
||
| 1095 | * @param string $function Legacy name of a controller "action", it's a unique within the controller like "read" |
||
| 1096 | * |
||
| 1097 | * @return \eZ\Publish\SPI\Limitation\Type[] |
||
| 1098 | * |
||
| 1099 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If module/function to limitation type mapping |
||
| 1100 | * refers to a non existing identifier. |
||
| 1101 | */ |
||
| 1102 | public function getLimitationTypesByModuleFunction($module, $function) |
||
| 1106 | } |
||
| 1107 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: