instances added god may help
This commit is contained in:
61
lib/Service/Import/Profile/DepartmentImportGateway.php
Normal file
61
lib/Service/Import/Profile/DepartmentImportGateway.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Service\Import\Profile;
|
||||
|
||||
use MintyPHP\Repository\Org\DepartmentRepository;
|
||||
use MintyPHP\Repository\Tenant\TenantRepository;
|
||||
use MintyPHP\Service\Org\DepartmentService;
|
||||
|
||||
class DepartmentImportGateway
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ?DepartmentRepository $departmentRepository = null,
|
||||
private readonly ?TenantRepository $tenantRepository = null,
|
||||
private readonly ?DepartmentService $departmentService = null
|
||||
) {
|
||||
}
|
||||
|
||||
public function findTenantByUuid(string $uuid): ?array
|
||||
{
|
||||
return $this->tenantRepository()->findByUuid($uuid);
|
||||
}
|
||||
|
||||
public function findTenantById(int $id): ?array
|
||||
{
|
||||
return $this->tenantRepository()->find($id);
|
||||
}
|
||||
|
||||
public function existsDepartmentCode(string $code): bool
|
||||
{
|
||||
return $this->departmentRepository()->existsByCode($code);
|
||||
}
|
||||
|
||||
public function existsDepartmentByTenantAndDescription(int $tenantId, string $description): bool
|
||||
{
|
||||
return $this->departmentRepository()->existsByTenantAndDescription($tenantId, $description);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function createDepartmentFromAdmin(array $input, int $currentUserId): array
|
||||
{
|
||||
return $this->departmentService()->createFromAdmin($input, $currentUserId);
|
||||
}
|
||||
|
||||
private function departmentRepository(): DepartmentRepository
|
||||
{
|
||||
return $this->departmentRepository ?? new DepartmentRepository();
|
||||
}
|
||||
|
||||
private function tenantRepository(): TenantRepository
|
||||
{
|
||||
return $this->tenantRepository ?? new TenantRepository();
|
||||
}
|
||||
|
||||
private function departmentService(): DepartmentService
|
||||
{
|
||||
return $this->departmentService ?? new DepartmentService();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user