/** * @inheritdoc */ public function create(UserRightSpecInterface $spec) { $userId = $spec->getUserId(); $action = $spec->getAction(); $object = $spec->getObject(); $rightId = $this->rightService->getRight($action, $object)->getId(); $forObjectGroup = $spec->getForObjectGroup(); $withId = $spec->getWithObjectId(); return $this->userRightService->createUserRight($userId, $rightId, $forObjectGroup, $withId); }
public function existsUserRight($userId, $rightId, $forObject, $withId) { Assertion::nullOrInteger($userId); Assertion::integer($rightId); Assertion::nullOrString($forObject); //If there is no forObject, there can not be an withId if ($forObject === null) { Assertion::same($withId, null); } else { Assertion::nullOrString($withId); } if ($userId !== null && !$this->userService->existsUserById($userId)) { throw new UserDoesNotExistException(); } if (!$this->rightService->existsRightById($rightId)) { throw new RightNotFoundException(); } return $this->getORMUserRight($userId, $rightId, $forObject, $withId) !== null; }