Files
contabilidad/console/common/Command/Consolidar.php

38 lines
1.1 KiB
PHP
Raw Normal View History

2022-03-25 10:11:02 -03:00
<?php
namespace Contabilidad\Common\Command;
use Psr\Http\Client\ClientInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Consolidar extends Command {
protected $client;
public function __construct(ClientInterface $client = null, string $name = null) {
parent::__construct($name);
$this->setClient($client);
}
public function setClient(ClientInterface $client) {
$this->client = $client;
return $this;
}
public function getClient(): ClientInterface {
return $this->client;
}
public function execute(InputInterface $input, OutputInterface $output) {
try {
$response = $this->getClient()->get('/consolidar');
if ($response->getStatusCode() === 200) {
2022-03-25 15:04:10 -03:00
return Command::SUCCESS;
2022-03-25 10:11:02 -03:00
}
2022-03-25 15:04:10 -03:00
error_log($response->getReasonPhrase());
return Command::FAILURE;
2022-03-25 10:11:02 -03:00
} catch (\Exception $e) {
error_log($e);
2022-03-25 15:04:10 -03:00
return Command::FAILURE;
2022-03-25 10:11:02 -03:00
}
}
}