本文整理汇总了PHP中eZ\Publish\Core\REST\Common\Input\ParserTools::parseLimitation方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserTools::parseLimitation方法的具体用法?PHP ParserTools::parseLimitation怎么用?PHP ParserTools::parseLimitation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\Core\REST\Common\Input\ParserTools
的用法示例。
在下文中一共展示了ParserTools::parseLimitation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse input structure
*
* @param array $data
* @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
*
* @return \eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct
*/
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
{
$policyUpdate = $this->roleService->newPolicyUpdateStruct();
// @todo XSD says that limitations field is mandatory, but
// it needs to be possible to remove limitations from policy
if (array_key_exists('limitations', $data)) {
if (!is_array($data['limitations'])) {
throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyUpdate.");
}
if (!isset($data['limitations']['limitation']) || !is_array($data['limitations']['limitation'])) {
throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyUpdate.");
}
foreach ($data['limitations']['limitation'] as $limitationData) {
$policyUpdate->addLimitation($this->parserTools->parseLimitation($limitationData));
}
}
return $policyUpdate;
}
示例2: parse
/**
* Parse input structure
*
* @param array $data
* @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
*
* @return \eZ\Publish\Core\REST\Server\Values\RoleAssignment
*/
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
{
if (!array_key_exists('Role', $data)) {
throw new Exceptions\Parser("Missing 'Role' element for RoleAssignInput.");
}
if (!is_array($data['Role']) || !array_key_exists('_href', $data['Role'])) {
throw new Exceptions\Parser("Invalid 'Role' element for RoleAssignInput.");
}
try {
$roleId = $this->requestParser->parseHref($data['Role']['_href'], 'roleId');
} catch (Exceptions\InvalidArgumentException $e) {
throw new Exceptions\Parser('Invalid format for <Role> reference in <RoleAssignInput>.');
}
// @todo XSD says that limitation is mandatory, but roles can be assigned without limitations
$limitation = null;
if (array_key_exists('limitation', $data) && is_array($data['limitation'])) {
$limitation = $this->parserTools->parseLimitation($data['limitation']);
}
return new RoleAssignment($roleId, $limitation);
}
示例3: parse
/**
* Parse input structure
*
* @param array $data
* @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
*
* @return \eZ\Publish\API\Repository\Values\User\PolicyCreateStruct
*/
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
{
if (!array_key_exists('module', $data)) {
throw new Exceptions\Parser("Missing 'module' attribute for PolicyCreate.");
}
if (!array_key_exists('function', $data)) {
throw new Exceptions\Parser("Missing 'function' attribute for PolicyCreate.");
}
$policyCreate = $this->roleService->newPolicyCreateStruct($data['module'], $data['function']);
// @todo XSD says that limitations is mandatory,
// but polices can be created without limitations
if (array_key_exists('limitations', $data)) {
if (!is_array($data['limitations'])) {
throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyCreate.");
}
if (!isset($data['limitations']['limitation']) || !is_array($data['limitations']['limitation'])) {
throw new Exceptions\Parser("Invalid format for 'limitations' in PolicyCreate.");
}
foreach ($data['limitations']['limitation'] as $limitationData) {
$policyCreate->addLimitation($this->parserTools->parseLimitation($limitationData));
}
}
return $policyCreate;
}