Refactor AcmeService creation into Factory

This commit is contained in:
Niklas Keller
2016-03-25 20:04:58 +01:00
parent e4b9203537
commit 2b2daee8bb
5 changed files with 35 additions and 13 deletions

View File

@@ -5,11 +5,11 @@ namespace Kelunik\AcmeClient\Commands;
use Amp\CoroutineResult;
use Amp\Dns\Record;
use Exception;
use Kelunik\Acme\AcmeClient;
use Kelunik\Acme\AcmeException;
use Kelunik\Acme\AcmeService;
use Kelunik\Acme\KeyPair;
use Kelunik\Acme\OpenSSLKeyGenerator;
use Kelunik\AcmeClient\AcmeFactory;
use Kelunik\AcmeClient\Stores\CertificateStore;
use Kelunik\AcmeClient\Stores\ChallengeStore;
use Kelunik\AcmeClient\Stores\KeyStore;
@@ -21,9 +21,11 @@ use Throwable;
class Issue implements Command {
private $climate;
private $acmeFactory;
public function __construct(CLImate $climate) {
public function __construct(CLImate $climate, AcmeFactory $acmeFactory) {
$this->climate = $climate;
$this->acmeFactory = $acmeFactory;
}
public function execute(Manager $args) {
@@ -77,7 +79,7 @@ class Issue implements Command {
$this->climate->br();
$acme = new AcmeService(new AcmeClient($server, $keyPair));
$acme = $this->acmeFactory->build($server, $keyPair);
$promises = [];
foreach ($domains as $i => $domain) {