37 lines
944 B
PHP
37 lines
944 B
PHP
<?php
|
|
namespace ProVM\Command;
|
|
|
|
use Exception;
|
|
use PDOException;
|
|
use Psr\Log\LoggerInterface;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use ProVM\Service\Remote;
|
|
|
|
#[AsCommand(
|
|
name: 'update',
|
|
hidden: false
|
|
)]
|
|
class UpdateIp extends Command
|
|
{
|
|
public function __construct(protected Remote $service, protected LoggerInterface $logger, string $name = 'update')
|
|
{
|
|
parent::__construct($name);
|
|
}
|
|
|
|
public function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
try {
|
|
$this->service->update();
|
|
return Command::SUCCESS;
|
|
} catch (PDOException $e) {
|
|
$this->logger->warning($e);
|
|
return Command::FAILURE;
|
|
} catch (Exception $e) {
|
|
$this->logger->error($e);
|
|
return Command::FAILURE;
|
|
}
|
|
}
|
|
}
|