Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZEE-3465: Refactored RepositoryConfigurationProvider #3085

Merged
merged 10 commits into from
Feb 12, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ public function getRepositoryConfig()
// Takes configured repository as the reference, if it exists.
// If not, the first configured repository is considered instead.
$repositoryAlias = $this->configResolver->getParameter('repository');
if ($repositoryAlias === null) {
$aliases = array_keys($this->repositories);
$repositoryAlias = array_shift($aliases);
}
$repositoryAlias = $repositoryAlias ?: $this->pullDefaultRepository();

if (empty($repositoryAlias) || !isset($this->repositories[$repositoryAlias])) {
throw new InvalidRepositoryException(
Expand All @@ -54,6 +51,13 @@ public function getRepositoryConfig()
return ['alias' => $repositoryAlias] + $this->repositories[$repositoryAlias];
}

public function pullDefaultRepository(): ?string
barw4 marked this conversation as resolved.
Show resolved Hide resolved
{
$aliases = array_keys($this->repositories);

return array_shift($aliases);
Comment on lines +61 to +63
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be replaced by https://www.php.net/manual/en/function.array-key-first during merge up to 3.x

}

public function getStorageConnectionName(): string
{
$repositoryConfig = $this->getRepositoryConfig();
Expand All @@ -62,4 +66,9 @@ public function getStorageConnectionName(): string
? $repositoryConfig[self::REPOSITORY_STORAGE][self::REPOSITORY_CONNECTION]
: self::DEFAULT_CONNECTION_NAME;
}

public function getRepositories(): array
barw4 marked this conversation as resolved.
Show resolved Hide resolved
{
return $this->repositories;
}
}