mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-08 00:03:12 +08:00
Removed more functional-php usages
This commit is contained in:
@@ -15,8 +15,6 @@ use Shlinkio\Shlink\Rest\ApiKey\Role;
|
||||
use Shlinkio\Shlink\Rest\Entity\ApiKey;
|
||||
|
||||
use function array_map;
|
||||
use function Functional\first;
|
||||
use function Functional\group;
|
||||
|
||||
class DomainService implements DomainServiceInterface
|
||||
{
|
||||
@@ -49,12 +47,19 @@ class DomainService implements DomainServiceInterface
|
||||
{
|
||||
/** @var DomainRepositoryInterface $repo */
|
||||
$repo = $this->em->getRepository(Domain::class);
|
||||
$groups = group(
|
||||
$repo->findDomains($apiKey),
|
||||
fn (Domain $domain) => $domain->authority === $this->defaultDomain ? 'default' : 'domains',
|
||||
);
|
||||
$allDomains = $repo->findDomains($apiKey);
|
||||
$defaultDomain = null;
|
||||
$restOfDomains = [];
|
||||
|
||||
return [first($groups['default'] ?? []), $groups['domains'] ?? []];
|
||||
foreach ($allDomains as $domain) {
|
||||
if ($domain->authority === $this->defaultDomain) {
|
||||
$defaultDomain = $domain;
|
||||
} else {
|
||||
$restOfDomains[] = $domain;
|
||||
}
|
||||
}
|
||||
|
||||
return [$defaultDomain, $restOfDomains];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user