本文整理匯總了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;
}