Timezone por DI

This commit is contained in:
Juan Pablo Vial
2025-05-27 16:19:47 -04:00
parent aed26cfcd8
commit b7089f7a1c
3 changed files with 10 additions and 6 deletions

View File

@ -15,12 +15,12 @@ use Incoviba\Service\Schedule;
)]
class BaseLoop extends Console\Command\Command
{
public function __construct(protected LoggerInterface $logger, protected Schedule $scheduleService, ?string $name = null)
public function __construct(protected LoggerInterface $logger, protected Schedule $scheduleService,
protected DateTimeZone $timezone,
?string $name = null)
{
parent::__construct($name);
$this->timezone = new DateTimeZone($_ENV['TZ'] ?? 'America/Santiago');
}
protected DateTimeZone $timezone;
public function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
{
@ -59,6 +59,7 @@ class BaseLoop extends Console\Command\Command
$command = $this->getApplication()->find($commandName);
} catch (Console\Exception\CommandNotFoundException $exception) {
$this->logger->warning($exception);
return self::FAILURE;
}
$cmd = new Console\Input\ArrayInput([