Clean up code.

This commit is contained in:
James Cole
2025-05-04 17:41:26 +02:00
parent e28e538272
commit 0573bf2402
147 changed files with 1758 additions and 1770 deletions

View File

@@ -31,15 +31,15 @@ use Illuminate\Contracts\Auth\Authenticatable;
interface UserGroupInterface
{
public function getUserGroup(): ?UserGroup;
public function checkUserGroupAccess(UserRoleEnum $role): bool;
public function getUser(): ?User;
public function checkUserGroupAccess(UserRoleEnum $role): bool;
public function setUserGroup(UserGroup $userGroup): void;
public function getUserGroup(): ?UserGroup;
public function setUser(null|Authenticatable|User $user): void;
public function setUserGroup(UserGroup $userGroup): void;
public function setUserGroupById(int $userGroupId): void;
}

View File

@@ -40,16 +40,6 @@ trait UserGroupTrait
protected ?User $user = null;
protected ?UserGroup $userGroup = null;
public function getUserGroup(): ?UserGroup
{
return $this->userGroup;
}
public function getUser(): ?User
{
return $this->user;
}
public function checkUserGroupAccess(UserRoleEnum $role): bool
{
$result = $this->user->hasRoleInGroupOrOwner($this->userGroup, $role);
@@ -63,15 +53,9 @@ trait UserGroupTrait
return false;
}
/**
* TODO This method does not check if the user has access to this particular user group.
*/
public function setUserGroup(UserGroup $userGroup): void
public function getUser(): ?User
{
if (null === $this->user) {
Log::warning(sprintf('User is not set in repository %s', static::class));
}
$this->userGroup = $userGroup;
return $this->user;
}
/**
@@ -92,6 +76,22 @@ trait UserGroupTrait
throw new FireflyException(sprintf('Object is of class %s, not User.', $user::class));
}
public function getUserGroup(): ?UserGroup
{
return $this->userGroup;
}
/**
* TODO This method does not check if the user has access to this particular user group.
*/
public function setUserGroup(UserGroup $userGroup): void
{
if (null === $this->user) {
Log::warning(sprintf('User is not set in repository %s', static::class));
}
$this->userGroup = $userGroup;
}
/**
* @throws FireflyException
*/