| @@ 179-208 (lines=30) @@ | ||
| 176 | * |
|
| 177 | * @return \eZ\Publish\API\Repository\Values\User\RoleDraft |
|
| 178 | */ |
|
| 179 | public function loadRoleDraft($id) |
|
| 180 | { |
|
| 181 | $response = $this->client->request( |
|
| 182 | 'GET', |
|
| 183 | $id, |
|
| 184 | new Message( |
|
| 185 | array('Accept' => $this->outputVisitor->getMediaType('RoleDraft')) |
|
| 186 | ) |
|
| 187 | ); |
|
| 188 | ||
| 189 | $loadedRoleDraft = $this->inputDispatcher->parse($response); |
|
| 190 | $loadedRoleDraftValues = $this->requestParser->parse('role', $loadedRoleDraft->id); |
|
| 191 | $response = $this->client->request( |
|
| 192 | 'GET', |
|
| 193 | $this->requestParser->generate('policies', array('role' => $loadedRoleDraftValues['role'])), |
|
| 194 | new Message( |
|
| 195 | array('Accept' => $this->outputVisitor->getMediaType('PolicyList')) |
|
| 196 | ) |
|
| 197 | ); |
|
| 198 | ||
| 199 | $policies = $this->inputDispatcher->parse($response); |
|
| 200 | ||
| 201 | return new RoleDraft( |
|
| 202 | array( |
|
| 203 | 'id' => $loadedRoleDraft->id, |
|
| 204 | 'identifier' => $loadedRoleDraft->identifier, |
|
| 205 | ), |
|
| 206 | $policies |
|
| 207 | ); |
|
| 208 | } |
|
| 209 | ||
| 210 | /** |
|
| 211 | * Loads a RoleDraft by the ID of the role it was created from. |
|
| @@ 666-695 (lines=30) @@ | ||
| 663 | * |
|
| 664 | * @return \eZ\Publish\API\Repository\Values\User\Role |
|
| 665 | */ |
|
| 666 | public function loadRole($id) |
|
| 667 | { |
|
| 668 | $response = $this->client->request( |
|
| 669 | 'GET', |
|
| 670 | $id, |
|
| 671 | new Message( |
|
| 672 | array('Accept' => $this->outputVisitor->getMediaType('Role')) |
|
| 673 | ) |
|
| 674 | ); |
|
| 675 | ||
| 676 | $loadedRole = $this->inputDispatcher->parse($response); |
|
| 677 | $loadedRoleValues = $this->requestParser->parse('role', $loadedRole->id); |
|
| 678 | $response = $this->client->request( |
|
| 679 | 'GET', |
|
| 680 | $this->requestParser->generate('policies', array('role' => $loadedRoleValues['role'])), |
|
| 681 | new Message( |
|
| 682 | array('Accept' => $this->outputVisitor->getMediaType('PolicyList')) |
|
| 683 | ) |
|
| 684 | ); |
|
| 685 | ||
| 686 | $policies = $this->inputDispatcher->parse($response); |
|
| 687 | ||
| 688 | return new Role( |
|
| 689 | array( |
|
| 690 | 'id' => $loadedRole->id, |
|
| 691 | 'identifier' => $loadedRole->identifier, |
|
| 692 | ), |
|
| 693 | $policies |
|
| 694 | ); |
|
| 695 | } |
|
| 696 | ||
| 697 | /** |
|
| 698 | * Loads a role for the given name. |
|