Repo Interface für tests
This commit is contained in:
@@ -5,7 +5,7 @@ namespace MintyPHP\Repository\Access;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class PermissionRepository
|
||||
class PermissionRepository implements PermissionRepositoryInterface
|
||||
{
|
||||
public function list(): array
|
||||
{
|
||||
|
||||
22
lib/Repository/Access/PermissionRepositoryInterface.php
Normal file
22
lib/Repository/Access/PermissionRepositoryInterface.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Access;
|
||||
|
||||
interface PermissionRepositoryInterface
|
||||
{
|
||||
public function list(): array;
|
||||
|
||||
public function listActive(): array;
|
||||
|
||||
public function listPaged(array $options): array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function findByKey(string $key): ?array;
|
||||
|
||||
public function create(array $data): ?int;
|
||||
|
||||
public function update(int $id, array $data): bool;
|
||||
|
||||
public function delete(int $id): bool;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Access;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class RolePermissionRepository
|
||||
class RolePermissionRepository implements RolePermissionRepositoryInterface
|
||||
{
|
||||
public function listPermissionIdsByRoleId(int $roleId): array
|
||||
{
|
||||
|
||||
20
lib/Repository/Access/RolePermissionRepositoryInterface.php
Normal file
20
lib/Repository/Access/RolePermissionRepositoryInterface.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Access;
|
||||
|
||||
interface RolePermissionRepositoryInterface
|
||||
{
|
||||
public function listPermissionIdsByRoleId(int $roleId): array;
|
||||
|
||||
public function countPermissionsByRoleIds(array $roleIds): array;
|
||||
|
||||
public function replaceForRole(int $roleId, array $permissionIds): bool;
|
||||
|
||||
public function listRoleIdsByPermissionId(int $permissionId): array;
|
||||
|
||||
public function replaceForPermission(int $permissionId, array $roleIds): bool;
|
||||
|
||||
public function listPermissionKeysByRoleIds(array $roleIds): array;
|
||||
|
||||
public function listPermissionsWithRolesByRoleIds(array $roleIds): array;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace MintyPHP\Repository\Access;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class RoleRepository
|
||||
class RoleRepository implements RoleRepositoryInterface
|
||||
{
|
||||
private function unwrap(?array $row): ?array
|
||||
{
|
||||
@@ -159,7 +159,7 @@ class RoleRepository
|
||||
return $count ? ((int) $count > 0) : false;
|
||||
}
|
||||
|
||||
public function create(array $data)
|
||||
public function create(array $data): mixed
|
||||
{
|
||||
return DB::insert(
|
||||
'insert into roles (uuid, description, code, active, created_by, created) values (?,?,?,?,?,NOW())',
|
||||
|
||||
30
lib/Repository/Access/RoleRepositoryInterface.php
Normal file
30
lib/Repository/Access/RoleRepositoryInterface.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Access;
|
||||
|
||||
interface RoleRepositoryInterface
|
||||
{
|
||||
public function list(): array;
|
||||
|
||||
public function listActive(): array;
|
||||
|
||||
public function listByIds(array $roleIds): array;
|
||||
|
||||
public function listIds(): array;
|
||||
|
||||
public function listActiveIds(): array;
|
||||
|
||||
public function listPaged(array $options): array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function findByUuid(string $uuid): ?array;
|
||||
|
||||
public function existsByCode(string $code, int $excludeId = 0): bool;
|
||||
|
||||
public function create(array $data): mixed;
|
||||
|
||||
public function update(int $id, array $data): bool;
|
||||
|
||||
public function delete(int $id): bool;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Access;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class UserRoleRepository
|
||||
class UserRoleRepository implements UserRoleRepositoryInterface
|
||||
{
|
||||
public function listRoleIdsByUserId(int $userId): array
|
||||
{
|
||||
|
||||
16
lib/Repository/Access/UserRoleRepositoryInterface.php
Normal file
16
lib/Repository/Access/UserRoleRepositoryInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Access;
|
||||
|
||||
interface UserRoleRepositoryInterface
|
||||
{
|
||||
public function listRoleIdsByUserId(int $userId): array;
|
||||
|
||||
public function replaceForUser(int $userId, array $roleIds): bool;
|
||||
|
||||
public function listUserIdsByRoleIds(array $roleIds): array;
|
||||
|
||||
public function countUsersByRoleIds(array $roleIds): array;
|
||||
|
||||
public function countActiveUsersByRoleIds(array $roleIds): array;
|
||||
}
|
||||
Reference in New Issue
Block a user