| @@ 56-77 (lines=22) @@ | ||
| 53 | * |
|
| 54 | * @return \eZ\Publish\API\Repository\Values\ValueObject |
|
| 55 | */ |
|
| 56 | public function parse(array $data, ParsingDispatcher $parsingDispatcher) |
|
| 57 | { |
|
| 58 | if (!array_key_exists('_identifier', $data)) { |
|
| 59 | throw new Exceptions\Parser("Missing '_identifier' attribute for Limitation."); |
|
| 60 | } |
|
| 61 | ||
| 62 | $limitationObject = $this->buildLimitation(); |
|
| 63 | ||
| 64 | if (!isset($data['values']['ref']) || !is_array($data['values']['ref'])) { |
|
| 65 | throw new Exceptions\Parser('Invalid format for data values in Limitation.'); |
|
| 66 | } |
|
| 67 | ||
| 68 | foreach ($data['values']['ref'] as $limitationValue) { |
|
| 69 | if (!array_key_exists('_href', $limitationValue)) { |
|
| 70 | throw new Exceptions\Parser('Invalid format for data values in Limitation.'); |
|
| 71 | } |
|
| 72 | ||
| 73 | $limitationObject->limitationValues[] = $this->parseIdFromHref($limitationValue); |
|
| 74 | } |
|
| 75 | ||
| 76 | return $limitationObject; |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * @return \eZ\Publish\API\Repository\Values\User\Limitation |
|
| @@ 58-81 (lines=24) @@ | ||
| 55 | * |
|
| 56 | * @return \eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct |
|
| 57 | */ |
|
| 58 | public function parse(array $data, ParsingDispatcher $parsingDispatcher) |
|
| 59 | { |
|
| 60 | $policyUpdate = $this->roleService->newPolicyUpdateStruct(); |
|
| 61 | ||
| 62 | // @todo XSD says that limitations field is mandatory, but |
|
| 63 | // it needs to be possible to remove limitations from policy |
|
| 64 | if (array_key_exists('limitations', $data)) { |
|
| 65 | if (!is_array($data['limitations'])) { |
|
| 66 | throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyUpdate."); |
|
| 67 | } |
|
| 68 | ||
| 69 | if (!isset($data['limitations']['limitation']) || !is_array($data['limitations']['limitation'])) { |
|
| 70 | throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyUpdate."); |
|
| 71 | } |
|
| 72 | ||
| 73 | foreach ($data['limitations']['limitation'] as $limitationData) { |
|
| 74 | $policyUpdate->addLimitation( |
|
| 75 | $this->parserTools->parseLimitation($limitationData) |
|
| 76 | ); |
|
| 77 | } |
|
| 78 | } |
|
| 79 | ||
| 80 | return $policyUpdate; |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||