add admin command
This commit is contained in:
parent
4462879b7d
commit
fee174ec05
7 changed files with 120 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\User;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class EnvironmentInitialAdminCredentialsProvider implements
|
||||
InitialAdminCredentialsProvider
|
||||
{
|
||||
public function getCredentials(): InitialAdminCredentials
|
||||
{
|
||||
return new InitialAdminCredentials(
|
||||
email: $this->requiredEnvironmentValue(
|
||||
'RABBI_GERZI_INITIAL_ADMIN_EMAIL',
|
||||
),
|
||||
password: $this->requiredEnvironmentValue(
|
||||
'RABBI_GERZI_INITIAL_ADMIN_PASSWORD',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
private function requiredEnvironmentValue(string $key): string
|
||||
{
|
||||
$value = getenv($key);
|
||||
if (! is_string($value) || trim($value) === '') {
|
||||
throw new RuntimeException("$key is required");
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue