/** * Loads all policies from roles which are assigned to a user or to user groups to which the user belongs * * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if a user with the given id was not found * * @param mixed $userId * * @return \eZ\Publish\API\Repository\Values\User\Policy[] */ public function loadPoliciesByUserId($userId) { $contentIds = array($userId); foreach ($this->userService->loadUserGroupsByUserId($userId) as $group) { $contentIds[] = $group->id; } $roleIds = array(); foreach ($contentIds as $contentId) { if (false === isset($this->content2roles[$contentId])) { continue; } foreach ($this->content2roles[$contentId] as $roleId) { $roleIds[] = $roleId; } } if (0 === count($roleIds)) { throw new NotFoundExceptionStub('What error code should be used?'); } $policies = array(); foreach ($roleIds as $roleId) { if (false === isset($this->role2policy[$roleId])) { continue; } foreach ($this->role2policy[$roleId] as $policyId) { $policy = $this->policies[$policyId]; $this->policies[$policyId] = $policies[] = new PolicyStub(array('id' => $policy->id, 'roleId' => $policy->roleId, 'module' => $policy->module, 'function' => $policy->function, 'limitations' => $policy->getLimitations())); } } return $policies; }
/** * Rollback transaction * * Rollback transaction, or throw exceptions if no transactions has been started. * * @throws \RuntimeException If no transaction has been started */ public function rollback() { if (0 === $this->transactionDepth) { throw new \RuntimeException('What error code should be used?'); } if ($this->contentService) { $this->contentService->rollback(); } if ($this->contentTypeService) { $this->contentTypeService->rollback(); } if ($this->languageService) { $this->languageService->rollback(); } if ($this->locationService) { $this->locationService->rollback(); } if ($this->roleService) { $this->roleService->rollback(); } if ($this->sectionService) { $this->sectionService->rollback(); } if ($this->trashService) { $this->trashService->rollback(); } if ($this->userService) { $this->userService->rollback(); } --$this->transactionDepth; }