Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

PolicyUpdate.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\REST\Server\Input\Parser;
8
9 use eZ\Publish\Core\REST\Common\Input\BaseParser;
10 use eZ\Publish\Core\REST\Common\Input\ParsingDispatcher;
11 use eZ\Publish\Core\REST\Common\Input\ParserTools;
12 use eZ\Publish\Core\REST\Common\Exceptions;
13 use eZ\Publish\API\Repository\RoleService;
14
18 class PolicyUpdate extends BaseParser
19 {
25 protected $roleService;
26
32 protected $parserTools;
33
40 public function __construct(RoleService $roleService, ParserTools $parserTools)
41 {
42 $this->roleService = $roleService;
43 $this->parserTools = $parserTools;
44 }
45
54 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
55 {
56 $policyUpdate = $this->roleService->newPolicyUpdateStruct();
57
58 // @todo XSD says that limitations field is mandatory, but
59 // it needs to be possible to remove limitations from policy
60 if (array_key_exists('limitations', $data)) {
61 if (!is_array($data['limitations'])) {
62 throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyUpdate.");
63 }
64
65 if (!isset($data['limitations']['limitation']) || !is_array($data['limitations']['limitation'])) {
66 throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyUpdate.");
67 }
68
69 foreach ($data['limitations']['limitation'] as $limitationData) {
70 $policyUpdate->addLimitation(
71 $this->parserTools->parseLimitation($limitationData)
72 );
73 }
74 }
75
76 return $policyUpdate;
77 }
78 }
eZ\Publish\Core\REST\Common\Input\BaseParser
Definition: BaseParser.php:12
eZ\Publish\Core\REST\Common\Input\ParserTools
Tools object to be used in Input Parsers.
Definition: ParserTools.php:17
eZ\Publish\Core\REST\Common\Input\ParsingDispatcher
Parsing dispatcher.
Definition: ParsingDispatcher.php:15
eZ\Publish\Core\REST\Server\Input\Parser\PolicyUpdate
Parser for PolicyUpdate.
Definition: PolicyUpdate.php:19
eZ\Publish\Core\REST\Server\Input\Parser\PolicyUpdate\$parserTools
$parserTools
Definition: PolicyUpdate.php:32
eZ\Publish\Core\REST\Server\Input\Parser\PolicyUpdate\$roleService
$roleService
Definition: PolicyUpdate.php:25
eZ\Publish\Core\REST\Server\Input\Parser\PolicyUpdate\parse
parse(array $data, ParsingDispatcher $parsingDispatcher)
Parse input structure.
Definition: PolicyUpdate.php:54
eZ\Publish\Core\REST\Server\Input\Parser\PolicyUpdate\__construct
__construct(RoleService $roleService, ParserTools $parserTools)
Construct.
Definition: PolicyUpdate.php:40
eZ\Publish\API\Repository\RoleService
This service provides methods for managing Roles and Policies.
Definition: API/Repository/RoleService.php:26
eZ\Publish\Core\REST\Common\Exceptions
Definition: Core/REST/Common/Exceptions/ForbiddenException.php:7
eZ\Publish\Core\REST\Server\Input\Parser
Definition: ContentCreate.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.