#!/usr/bin/env php
<?php

declare(strict_types=1);

/*
 * This file is part of Contao.
 *
 * (c) Leo Feyer
 *
 * @license LGPL-3.0-or-later
 */

use Contao\ManagerBundle\Console\ContaoApplication;
use Contao\ManagerBundle\HttpKernel\ContaoKernel;
use Symfony\Component\Console\Input\ArgvInput;

set_time_limit(0);
@ini_set('zlib.output_compression', '0');
@ini_set('display_errors', '0');

// System maintenance mode comes first as it has to work even if the vendor directory does not exist
if ('contao:cron' === ($_SERVER['argv'][1] ?? null) && file_exists(__DIR__.'/../var/maintenance.html')) {
    exit;
}

require __DIR__.'/../vendor/autoload.php';

$input = new ArgvInput();
$kernel = ContaoKernel::fromInput(\dirname(__DIR__), $input);

$application = new ContaoApplication($kernel);
$application->run($input);
