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;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace MintyPHP\Repository\Audit;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class ApiAuditLogRepository
|
||||
class ApiAuditLogRepository implements ApiAuditLogRepositoryInterface
|
||||
{
|
||||
private const FILTER_OPTIONS_LIMIT_MAX = 200;
|
||||
|
||||
|
||||
16
lib/Repository/Audit/ApiAuditLogRepositoryInterface.php
Normal file
16
lib/Repository/Audit/ApiAuditLogRepositoryInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Audit;
|
||||
|
||||
interface ApiAuditLogRepositoryInterface
|
||||
{
|
||||
public function create(array $data): int|false;
|
||||
|
||||
public function listPaged(array $filters): array;
|
||||
|
||||
public function listFilterOptions(int $limit = 200): array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function purgeOlderThanDays(int $days): int;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use MintyPHP\Domain\Taxonomy\ImportAuditStatus;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class ImportAuditRunRepository
|
||||
class ImportAuditRunRepository implements ImportAuditRunRepositoryInterface
|
||||
{
|
||||
private const FILTER_OPTIONS_LIMIT_MAX = 200;
|
||||
|
||||
|
||||
18
lib/Repository/Audit/ImportAuditRunRepositoryInterface.php
Normal file
18
lib/Repository/Audit/ImportAuditRunRepositoryInterface.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Audit;
|
||||
|
||||
interface ImportAuditRunRepositoryInterface
|
||||
{
|
||||
public function createRunning(array $data): int|false;
|
||||
|
||||
public function finishById(int $id, array $data): bool;
|
||||
|
||||
public function listPaged(array $filters): array;
|
||||
|
||||
public function listFilterOptions(int $limit = 200): array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function purgeOlderThanDays(int $days): int;
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use MintyPHP\Domain\Taxonomy\SystemAuditOutcome;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class SystemAuditLogRepository
|
||||
class SystemAuditLogRepository implements SystemAuditLogRepositoryInterface
|
||||
{
|
||||
private const FILTER_OPTIONS_LIMIT_MAX = 200;
|
||||
|
||||
|
||||
16
lib/Repository/Audit/SystemAuditLogRepositoryInterface.php
Normal file
16
lib/Repository/Audit/SystemAuditLogRepositoryInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Audit;
|
||||
|
||||
interface SystemAuditLogRepositoryInterface
|
||||
{
|
||||
public function create(array $data): int|false;
|
||||
|
||||
public function listPaged(array $filters): array;
|
||||
|
||||
public function listFilterOptions(int $limit = 200): array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function purgeOlderThanDays(int $days): int;
|
||||
}
|
||||
@@ -8,7 +8,7 @@ use MintyPHP\Domain\Taxonomy\UserLifecycleTriggerType;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class UserLifecycleAuditRepository
|
||||
class UserLifecycleAuditRepository implements UserLifecycleAuditRepositoryInterface
|
||||
{
|
||||
private const FILTER_OPTIONS_LIMIT_MAX = 200;
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Audit;
|
||||
|
||||
interface UserLifecycleAuditRepositoryInterface
|
||||
{
|
||||
public function create(array $row): int|false;
|
||||
|
||||
public function updateStatus(int $id, string $status, ?string $reasonCode = null): bool;
|
||||
|
||||
public function listPaged(array $filters): array;
|
||||
|
||||
public function listFilterOptions(int $limit = 200): array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function findDeleteEventForRestore(int $id, bool $forUpdate = false): ?array;
|
||||
|
||||
public function markRestored(int $id, int $restoredBy, int $restoredUserId): bool;
|
||||
|
||||
public function purgeOlderThanDays(int $days): int;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace MintyPHP\Repository\Auth;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class ApiTokenRepository
|
||||
class ApiTokenRepository implements ApiTokenRepositoryInterface
|
||||
{
|
||||
private const UUID_REGEX = '/^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i';
|
||||
|
||||
|
||||
44
lib/Repository/Auth/ApiTokenRepositoryInterface.php
Normal file
44
lib/Repository/Auth/ApiTokenRepositoryInterface.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Auth;
|
||||
|
||||
interface ApiTokenRepositoryInterface
|
||||
{
|
||||
public function isUuid(string $value): bool;
|
||||
|
||||
public function create(
|
||||
int $userId,
|
||||
string $name,
|
||||
string $selector,
|
||||
string $tokenHash,
|
||||
?int $tenantId,
|
||||
?string $expiresAt,
|
||||
?int $createdBy
|
||||
): ?int;
|
||||
|
||||
public function findBySelector(string $selector): ?array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function findByUuid(string $uuid): ?array;
|
||||
|
||||
public function findByUuidForUser(string $uuid, int $userId): ?array;
|
||||
|
||||
public function updateLastUsed(int $id, string $ip): bool;
|
||||
|
||||
public function revoke(int $id): bool;
|
||||
|
||||
public function revokeByUuidForUser(string $uuid, int $userId): bool;
|
||||
|
||||
public function revokeAllForUser(int $userId, ?int $tenantId = null): int;
|
||||
|
||||
public function revokeAllActiveByAdmin(): int;
|
||||
|
||||
public function listByUserId(int $userId, int $limit = 25): array;
|
||||
|
||||
public function countActiveForUser(int $userId): int;
|
||||
|
||||
public function countActiveForUserExcludingId(int $userId, int $excludeId): int;
|
||||
|
||||
public function countActive(): int;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Auth;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class EmailVerificationRepository
|
||||
class EmailVerificationRepository implements EmailVerificationRepositoryInterface
|
||||
{
|
||||
public function create(int $userId, string $codeHash, string $expiresAt): ?int
|
||||
{
|
||||
|
||||
18
lib/Repository/Auth/EmailVerificationRepositoryInterface.php
Normal file
18
lib/Repository/Auth/EmailVerificationRepositoryInterface.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Auth;
|
||||
|
||||
interface EmailVerificationRepositoryInterface
|
||||
{
|
||||
public function create(int $userId, string $codeHash, string $expiresAt): ?int;
|
||||
|
||||
public function invalidateForUser(int $userId): bool;
|
||||
|
||||
public function findActiveByUserId(int $userId): ?array;
|
||||
|
||||
public function findById(int $id): ?array;
|
||||
|
||||
public function incrementAttempts(int $id): bool;
|
||||
|
||||
public function markUsed(int $id): bool;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Auth;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class PasswordResetRepository
|
||||
class PasswordResetRepository implements PasswordResetRepositoryInterface
|
||||
{
|
||||
private function unwrapList($rows): array
|
||||
{
|
||||
|
||||
20
lib/Repository/Auth/PasswordResetRepositoryInterface.php
Normal file
20
lib/Repository/Auth/PasswordResetRepositoryInterface.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Auth;
|
||||
|
||||
interface PasswordResetRepositoryInterface
|
||||
{
|
||||
public function create(int $userId, string $codeHash, string $expiresAt): ?int;
|
||||
|
||||
public function invalidateForUser(int $userId): bool;
|
||||
|
||||
public function findActiveByUserId(int $userId): ?array;
|
||||
|
||||
public function findById(int $id): ?array;
|
||||
|
||||
public function incrementAttempts(int $id): bool;
|
||||
|
||||
public function markUsed(int $id): bool;
|
||||
|
||||
public function listByUserId(int $userId, int $limit = 20): array;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Auth;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class RememberTokenRepository
|
||||
class RememberTokenRepository implements RememberTokenRepositoryInterface
|
||||
{
|
||||
private function unwrapList($rows): array
|
||||
{
|
||||
|
||||
22
lib/Repository/Auth/RememberTokenRepositoryInterface.php
Normal file
22
lib/Repository/Auth/RememberTokenRepositoryInterface.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Auth;
|
||||
|
||||
interface RememberTokenRepositoryInterface
|
||||
{
|
||||
public function create(int $userId, string $selector, string $tokenHash, string $expiresAt): ?int;
|
||||
|
||||
public function findBySelector(string $selector): ?array;
|
||||
|
||||
public function updateToken(int $id, string $tokenHash, string $expiresAt): bool;
|
||||
|
||||
public function expireAllByAdmin(): int;
|
||||
|
||||
public function deleteById(int $id): bool;
|
||||
|
||||
public function deleteByUserId(int $userId): bool;
|
||||
|
||||
public function listByUserId(int $userId, int $limit = 20): array;
|
||||
|
||||
public function countActive(): int;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use MintyPHP\Domain\Taxonomy\MailLogStatus;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class MailLogRepository
|
||||
class MailLogRepository implements MailLogRepositoryInterface
|
||||
{
|
||||
public function create(array $data): ?int
|
||||
{
|
||||
|
||||
16
lib/Repository/Mail/MailLogRepositoryInterface.php
Normal file
16
lib/Repository/Mail/MailLogRepositoryInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Mail;
|
||||
|
||||
interface MailLogRepositoryInterface
|
||||
{
|
||||
public function create(array $data): ?int;
|
||||
|
||||
public function markSent(int $id, ?string $providerMessageId = null): bool;
|
||||
|
||||
public function markFailed(int $id, string $errorMessage): bool;
|
||||
|
||||
public function listPaged(array $options): array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace MintyPHP\Repository\Org;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class DepartmentRepository
|
||||
class DepartmentRepository implements DepartmentRepositoryInterface
|
||||
{
|
||||
private function unwrap(?array $row): ?array
|
||||
{
|
||||
@@ -284,7 +284,7 @@ class DepartmentRepository
|
||||
return $count ? (int) $count : 0;
|
||||
}
|
||||
|
||||
public function create(array $data)
|
||||
public function create(array $data): mixed
|
||||
{
|
||||
return DB::insert(
|
||||
'insert into departments (uuid, description, tenant_id, code, cost_center, active, created_by, created) values (?,?,?,?,?,?,?,NOW())',
|
||||
|
||||
36
lib/Repository/Org/DepartmentRepositoryInterface.php
Normal file
36
lib/Repository/Org/DepartmentRepositoryInterface.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Org;
|
||||
|
||||
interface DepartmentRepositoryInterface
|
||||
{
|
||||
public function list(): array;
|
||||
|
||||
public function listIds(): array;
|
||||
|
||||
public function listActiveIdsByTenantIds(array $tenantIds): array;
|
||||
|
||||
public function listByTenantIds(array $tenantIds): array;
|
||||
|
||||
public function listByIds(array $departmentIds, bool $includeInactive = false): 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 existsByTenantAndDescription(int $tenantId, string $description, int $excludeId = 0): bool;
|
||||
|
||||
public function countByTenantId(int $tenantId): int;
|
||||
|
||||
public function create(array $data): mixed;
|
||||
|
||||
public function update(int $id, array $data): bool;
|
||||
|
||||
public function setTenant(int $id, int $tenantId): bool;
|
||||
|
||||
public function delete(int $id): bool;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Org;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class UserDepartmentRepository
|
||||
class UserDepartmentRepository implements UserDepartmentRepositoryInterface
|
||||
{
|
||||
public function listDepartmentIdsByUserId(int $userId): array
|
||||
{
|
||||
|
||||
16
lib/Repository/Org/UserDepartmentRepositoryInterface.php
Normal file
16
lib/Repository/Org/UserDepartmentRepositoryInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Org;
|
||||
|
||||
interface UserDepartmentRepositoryInterface
|
||||
{
|
||||
public function listDepartmentIdsByUserId(int $userId): array;
|
||||
|
||||
public function replaceForUser(int $userId, array $departmentIds): bool;
|
||||
|
||||
public function removeInvalidForDepartment(int $departmentId): int;
|
||||
|
||||
public function countUsersByDepartmentIds(array $departmentIds): array;
|
||||
|
||||
public function countActiveUsersByDepartmentIds(array $departmentIds): array;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use MintyPHP\Domain\Taxonomy\ScheduledJobStatus;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class ScheduledJobRepository
|
||||
class ScheduledJobRepository implements ScheduledJobRepositoryInterface
|
||||
{
|
||||
public function create(array $data): int|false
|
||||
{
|
||||
|
||||
30
lib/Repository/Scheduler/ScheduledJobRepositoryInterface.php
Normal file
30
lib/Repository/Scheduler/ScheduledJobRepositoryInterface.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Scheduler;
|
||||
|
||||
interface ScheduledJobRepositoryInterface
|
||||
{
|
||||
public function create(array $data): int|false;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function findByKey(string $jobKey): ?array;
|
||||
|
||||
public function listPaged(array $filters): array;
|
||||
|
||||
public function listDueJobs(string $nowUtc, int $limit = 20): array;
|
||||
|
||||
public function updateJobMeta(int $id, array $data): bool;
|
||||
|
||||
public function markRunning(int $id, string $startedAtUtc): bool;
|
||||
|
||||
public function finishRun(
|
||||
int $id,
|
||||
string $status,
|
||||
string $startedAtUtc,
|
||||
string $finishedAtUtc,
|
||||
?string $nextRunAtUtc,
|
||||
?string $errorCode,
|
||||
?string $errorMessage
|
||||
): bool;
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use MintyPHP\Domain\Taxonomy\ScheduledJobTriggerType;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class ScheduledJobRunRepository
|
||||
class ScheduledJobRunRepository implements ScheduledJobRunRepositoryInterface
|
||||
{
|
||||
public function create(array $data): int|false
|
||||
{
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Scheduler;
|
||||
|
||||
interface ScheduledJobRunRepositoryInterface
|
||||
{
|
||||
public function create(array $data): int|false;
|
||||
|
||||
public function listPagedByJobId(int $jobId, array $filters): array;
|
||||
|
||||
public function purgeOlderThanDays(int $days): int;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace MintyPHP\Repository\Scheduler;
|
||||
use MintyPHP\Domain\Taxonomy\SchedulerRuntimeResult;
|
||||
use MintyPHP\DB;
|
||||
|
||||
class SchedulerRuntimeRepository
|
||||
class SchedulerRuntimeRepository implements SchedulerRuntimeRepositoryInterface
|
||||
{
|
||||
public function touchHeartbeat(string $result, ?string $errorCode = null, ?string $heartbeatAtUtc = null): bool
|
||||
{
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Scheduler;
|
||||
|
||||
interface SchedulerRuntimeRepositoryInterface
|
||||
{
|
||||
public function touchHeartbeat(string $result, ?string $errorCode = null, ?string $heartbeatAtUtc = null): bool;
|
||||
|
||||
public function findStatus(): ?array;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Search;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class SearchQueryRepository
|
||||
class SearchQueryRepository implements SearchQueryRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param array<int, mixed> $params
|
||||
|
||||
17
lib/Repository/Search/SearchQueryRepositoryInterface.php
Normal file
17
lib/Repository/Search/SearchQueryRepositoryInterface.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Search;
|
||||
|
||||
interface SearchQueryRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param array<int, mixed> $params
|
||||
* @return array<int, mixed>
|
||||
*/
|
||||
public function selectRows(string $sql, array $params = []): array;
|
||||
|
||||
/**
|
||||
* @param array<int, mixed> $params
|
||||
*/
|
||||
public function selectCount(string $sql, array $params = []): int;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Security;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class RateLimitRepository
|
||||
class RateLimitRepository implements RateLimitRepositoryInterface
|
||||
{
|
||||
public function findByScopeAndHash(string $scope, string $subjectHash): ?array
|
||||
{
|
||||
|
||||
25
lib/Repository/Security/RateLimitRepositoryInterface.php
Normal file
25
lib/Repository/Security/RateLimitRepositoryInterface.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Security;
|
||||
|
||||
interface RateLimitRepositoryInterface
|
||||
{
|
||||
public function findByScopeAndHash(string $scope, string $subjectHash): ?array;
|
||||
|
||||
public function create(
|
||||
string $scope,
|
||||
string $subjectHash,
|
||||
int $hits,
|
||||
string $windowStartedAt,
|
||||
?string $blockedUntil
|
||||
): bool;
|
||||
|
||||
public function updateStateById(
|
||||
int $id,
|
||||
int $hits,
|
||||
string $windowStartedAt,
|
||||
?string $blockedUntil
|
||||
): bool;
|
||||
|
||||
public function deleteByScopeAndHash(string $scope, string $subjectHash): bool;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Settings;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class SettingRepository
|
||||
class SettingRepository implements SettingRepositoryInterface
|
||||
{
|
||||
public function find(string $key): ?array
|
||||
{
|
||||
|
||||
12
lib/Repository/Settings/SettingRepositoryInterface.php
Normal file
12
lib/Repository/Settings/SettingRepositoryInterface.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Settings;
|
||||
|
||||
interface SettingRepositoryInterface
|
||||
{
|
||||
public function find(string $key): ?array;
|
||||
|
||||
public function getValue(string $key): ?string;
|
||||
|
||||
public function set(string $key, ?string $value, ?string $description = null): bool;
|
||||
}
|
||||
@@ -12,7 +12,7 @@ use MintyPHP\Domain\Taxonomy\UserLifecycleAction;
|
||||
use MintyPHP\Domain\Taxonomy\UserLifecycleStatus;
|
||||
use MintyPHP\DB;
|
||||
|
||||
class AdminStatsRepository
|
||||
class AdminStatsRepository implements AdminStatsRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
|
||||
11
lib/Repository/Stats/AdminStatsRepositoryInterface.php
Normal file
11
lib/Repository/Stats/AdminStatsRepositoryInterface.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Stats;
|
||||
|
||||
interface AdminStatsRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function buildViewData(): array;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Support;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class DatabaseSessionRepository
|
||||
class DatabaseSessionRepository implements DatabaseSessionRepositoryInterface
|
||||
{
|
||||
public function acquireAdvisoryLock(string $lockName, int $timeoutSeconds = 0): bool
|
||||
{
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Support;
|
||||
|
||||
interface DatabaseSessionRepositoryInterface
|
||||
{
|
||||
public function acquireAdvisoryLock(string $lockName, int $timeoutSeconds = 0): bool;
|
||||
|
||||
public function releaseAdvisoryLock(string $lockName): void;
|
||||
|
||||
public function beginTransaction(): void;
|
||||
|
||||
public function commitTransaction(): void;
|
||||
|
||||
public function rollbackTransaction(): void;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\Tenant;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class TenantMicrosoftAuthRepository
|
||||
class TenantMicrosoftAuthRepository implements TenantMicrosoftAuthRepositoryInterface
|
||||
{
|
||||
private function unwrap($row): ?array
|
||||
{
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Tenant;
|
||||
|
||||
interface TenantMicrosoftAuthRepositoryInterface
|
||||
{
|
||||
public function findByTenantId(int $tenantId): ?array;
|
||||
|
||||
public function listByTenantIds(array $tenantIds): array;
|
||||
|
||||
public function upsertByTenantId(int $tenantId, array $data): bool;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use MintyPHP\Domain\Taxonomy\TenantStatus;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class TenantRepository
|
||||
class TenantRepository implements TenantRepositoryInterface
|
||||
{
|
||||
private function unwrap(?array $row): ?array
|
||||
{
|
||||
@@ -168,7 +168,7 @@ class TenantRepository
|
||||
return $this->unwrap($row);
|
||||
}
|
||||
|
||||
public function create(array $data)
|
||||
public function create(array $data): mixed
|
||||
{
|
||||
return DB::insert(
|
||||
'insert into tenants (uuid, description, address, postal_code, city, country, region, vat_id, tax_number, phone, fax, email, support_email, support_phone, billing_email, website, privacy_url, imprint_url, primary_color, default_theme, allow_user_theme, status, status_changed_at, status_changed_by, created_by, created) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,NOW())',
|
||||
|
||||
26
lib/Repository/Tenant/TenantRepositoryInterface.php
Normal file
26
lib/Repository/Tenant/TenantRepositoryInterface.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Tenant;
|
||||
|
||||
interface TenantRepositoryInterface
|
||||
{
|
||||
public function list(): array;
|
||||
|
||||
public function listIds(): array;
|
||||
|
||||
public function listByIds(array $tenantIds): array;
|
||||
|
||||
public function listActiveIdsByIds(array $tenantIds): array;
|
||||
|
||||
public function listPaged(array $options): array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function findByUuid(string $uuid): ?array;
|
||||
|
||||
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\Tenant;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class UserTenantRepository
|
||||
class UserTenantRepository implements UserTenantRepositoryInterface
|
||||
{
|
||||
public function listTenantIdsByUserId(int $userId): array
|
||||
{
|
||||
|
||||
14
lib/Repository/Tenant/UserTenantRepositoryInterface.php
Normal file
14
lib/Repository/Tenant/UserTenantRepositoryInterface.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\Tenant;
|
||||
|
||||
interface UserTenantRepositoryInterface
|
||||
{
|
||||
public function listTenantIdsByUserId(int $userId): array;
|
||||
|
||||
public function replaceForUser(int $userId, array $tenantIds): bool;
|
||||
|
||||
public function countUsersByTenantIds(array $tenantIds): array;
|
||||
|
||||
public function countActiveUsersByTenantIds(array $tenantIds): array;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\User;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class UserExternalIdentityRepository
|
||||
class UserExternalIdentityRepository implements UserExternalIdentityRepositoryInterface
|
||||
{
|
||||
private function unwrap($row): ?array
|
||||
{
|
||||
@@ -39,7 +39,7 @@ class UserExternalIdentityRepository
|
||||
return $this->unwrap($row);
|
||||
}
|
||||
|
||||
public function createLink(array $data)
|
||||
public function createLink(array $data): mixed
|
||||
{
|
||||
return DB::insert(
|
||||
'insert into user_external_identities (user_id, provider, oid, tid, issuer, subject, email_at_link_time, created) values (?,?,?,?,?,?,?,NOW())',
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\User;
|
||||
|
||||
interface UserExternalIdentityRepositoryInterface
|
||||
{
|
||||
public function findByProviderTidOid(string $provider, string $tid, string $oid): ?array;
|
||||
|
||||
public function findByProviderIssuerSubject(string $provider, string $issuer, string $subject): ?array;
|
||||
|
||||
public function createLink(array $data): mixed;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace MintyPHP\Repository\User;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class UserListQueryRepository
|
||||
class UserListQueryRepository implements UserListQueryRepositoryInterface
|
||||
{
|
||||
private function buildUserFilters(array $options): array
|
||||
{
|
||||
|
||||
8
lib/Repository/User/UserListQueryRepositoryInterface.php
Normal file
8
lib/Repository/User/UserListQueryRepositoryInterface.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\User;
|
||||
|
||||
interface UserListQueryRepositoryInterface
|
||||
{
|
||||
public function listPaged(array $options): array;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace MintyPHP\Repository\User;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
class UserReadRepository
|
||||
class UserReadRepository implements UserReadRepositoryInterface
|
||||
{
|
||||
public function findAuthzSnapshot(int $userId): ?array
|
||||
{
|
||||
|
||||
20
lib/Repository/User/UserReadRepositoryInterface.php
Normal file
20
lib/Repository/User/UserReadRepositoryInterface.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\User;
|
||||
|
||||
interface UserReadRepositoryInterface
|
||||
{
|
||||
public function findAuthzSnapshot(int $userId): ?array;
|
||||
|
||||
public function find(int $id): ?array;
|
||||
|
||||
public function findByUuid(string $uuid): ?array;
|
||||
|
||||
public function findByEmail(string $email): ?array;
|
||||
|
||||
public function listPrivilegedUserIdsByPermissionKeys(array $permissionKeys): array;
|
||||
|
||||
public function listIdsForAutoDeactivate(int $days, array $excludedUserIds, int $limit = 500): array;
|
||||
|
||||
public function listIdsForAutoDelete(int $days, array $excludedUserIds, int $limit = 500): array;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace MintyPHP\Repository\User;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class UserSavedFilterRepository
|
||||
class UserSavedFilterRepository implements UserSavedFilterRepositoryInterface
|
||||
{
|
||||
private function unwrapList($rows): array
|
||||
{
|
||||
|
||||
14
lib/Repository/User/UserSavedFilterRepositoryInterface.php
Normal file
14
lib/Repository/User/UserSavedFilterRepositoryInterface.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\User;
|
||||
|
||||
interface UserSavedFilterRepositoryInterface
|
||||
{
|
||||
public function listByUserAndContext(int $userId, string $context): array;
|
||||
|
||||
public function countByUserAndContext(int $userId, string $context): int;
|
||||
|
||||
public function create(array $data): int|false;
|
||||
|
||||
public function deleteByUuidForUserAndContext(string $uuid, int $userId, string $context): bool;
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace MintyPHP\Repository\User;
|
||||
use MintyPHP\DB;
|
||||
use MintyPHP\Repository\Support\RepoQuery;
|
||||
|
||||
class UserWriteRepository
|
||||
class UserWriteRepository implements UserWriteRepositoryInterface
|
||||
{
|
||||
public function updateLastLogin(int $userId, string $provider = 'local'): void
|
||||
{
|
||||
|
||||
40
lib/Repository/User/UserWriteRepositoryInterface.php
Normal file
40
lib/Repository/User/UserWriteRepositoryInterface.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\User;
|
||||
|
||||
interface UserWriteRepositoryInterface
|
||||
{
|
||||
public function updateLastLogin(int $userId, string $provider = 'local'): void;
|
||||
|
||||
public function bumpAuthzVersion(int $userId): bool;
|
||||
|
||||
public function bumpAuthzVersionByUserIds(array $userIds): int;
|
||||
|
||||
public function create(array $data): int|false;
|
||||
|
||||
public function update(int $id, array $data): bool;
|
||||
|
||||
public function setActive(int $id, bool $active, ?int $changedBy = null): bool;
|
||||
|
||||
public function setCurrentTenant(int $id, int $tenantId): bool;
|
||||
|
||||
public function setActiveByUuids(array $uuids, bool $active, ?int $modifiedBy = null): bool;
|
||||
|
||||
public function setInactiveByIds(array $userIds, ?int $changedBy = null): int;
|
||||
|
||||
public function deleteByIds(array $userIds): int;
|
||||
|
||||
public function setLocale(int $id, string $locale): bool;
|
||||
|
||||
public function setTheme(int $id, string $theme): bool;
|
||||
|
||||
public function updateProfileFieldsFromSso(int $id, array $fields): bool;
|
||||
|
||||
public function setPassword(int $id, string $password): bool;
|
||||
|
||||
public function setEmailVerified(int $id): bool;
|
||||
|
||||
public function delete(int $id): bool;
|
||||
|
||||
public function deleteByUuids(array $uuids): bool;
|
||||
}
|
||||
Reference in New Issue
Block a user