/** * @inheritdoc */ public function visit(TreeNodeInterface $node, &$data) { $struct = $this->roleService->newRoleCreateStruct(''); $this->fillValueObject($struct, $data); if (isset($data['policies'])) { foreach ($data['policies'] as $policyStruct) { $struct->addPolicy($policyStruct); } } $this->roleService->createRole($struct); }
/** * Parse input structure. * * @param array $data * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher * * @return \eZ\Publish\API\Repository\Values\User\RoleCreateStruct */ public function parse(array $data, ParsingDispatcher $parsingDispatcher) { // Since RoleInput is used both for creating and updating role and identifier is not // required when updating role, we need to rely on PAPI to throw the exception on missing // identifier when creating a role // @todo Bring in line with XSD which says that identifier is required always $roleIdentifier = null; if (array_key_exists('identifier', $data)) { $roleIdentifier = $data['identifier']; } $roleCreateStruct = $this->roleService->newRoleCreateStruct($roleIdentifier); return $roleCreateStruct; }
/** * Instantiates a role create class. * * @param string $name * * @return \eZ\Publish\API\Repository\Values\User\RoleCreateStruct */ public function newRoleCreateStruct($name) { return $this->service->newRoleCreateStruct($name); }