Viewing File: /usr/local/cpanel/whostmgr/docroot/cgi/ncssl/source/src/Command/ReissueCommand.php
<?php
namespace App\Command;
use App\Exception\CertificateException;
use App\Service\Certificate\Certificate;
use App\Service\Certificate\CertificateTransfer;
use App\Service\Certificate\Reissue;
use App\Service\CpanelApi\Adapter\CliAdapter;
use App\Service\CpanelApi\CpanelApi;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(
name: 'app:reissue',
description: 'Reissue certificate command',
)]
class ReissueCommand extends Command
{
public function __construct(
private readonly CpanelApi $api,
private readonly Reissue $reissue,
private readonly Certificate $certificate,
private readonly LoggerInterface $logger,
){
parent::__construct();
}
protected function configure(): void
{
$this
->addArgument('domainName', InputArgument::REQUIRED, 'Domain name')
->addArgument('isAsync', InputArgument::OPTIONAL, 'Is Async Flow', false)
;
}
/**
* @throws CertificateException
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$adapter = $this->api->getAdapter();
if ($adapter instanceof CliAdapter) {
$adapter->setUsername($_SERVER['USER']);
}
$certificateTransfer = new CertificateTransfer([
'userName' => $_SERVER['USER'],
'domainName' => $input->getArgument('domainName'),
]);
$certificateTransfer = $this->certificate->getCertificate($certificateTransfer);
try {
$this->reissue->reissue($certificateTransfer);
} catch (\Throwable $exception) {
$this->logger->error(sprintf('Error occurred reissue request: %s', $exception->getMessage()));
return Command::FAILURE;
}
return Command::SUCCESS;
}
}
Back to Directory
File Manager