Files
Warner-Vistex-Automater/bootstrap.php
T
Stefan Lazic a451060c1b Initial
Takes in a file, process it and output a new file with additional columns.
2026-07-10 15:45:02 +01:00

71 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
session_start();
$appConfig = require __DIR__ . '/config.php';
$vendorAutoload = __DIR__ . '/vendor/autoload.php';
if (is_file($vendorAutoload)) {
require_once $vendorAutoload;
}
function app_config(string $path, mixed $default = null): mixed
{
global $appConfig;
$segments = explode('.', $path);
$value = $appConfig;
foreach ($segments as $segment) {
if (!is_array($value) || !array_key_exists($segment, $value)) {
return $default;
}
$value = $value[$segment];
}
return $value;
}
function asset_url(string $path): string
{
$path = ltrim($path, '/');
$scriptName = str_replace('\\', '/', (string) ($_SERVER['SCRIPT_NAME'] ?? ''));
$scriptDir = rtrim(dirname($scriptName), '/');
$documentRoot = rtrim(str_replace('\\', '/', (string) ($_SERVER['DOCUMENT_ROOT'] ?? '')), '/');
if ($documentRoot !== '' && str_ends_with($documentRoot, '/public')) {
$url = '/assets/' . $path;
} elseif ($scriptDir === '' || $scriptDir === '.') {
$url = '/public/assets/' . $path;
} elseif (str_ends_with($scriptDir, '/public')) {
$url = $scriptDir . '/assets/' . $path;
} else {
$url = $scriptDir . '/public/assets/' . $path;
}
$filesystemPath = __DIR__ . '/public/assets/' . $path;
if (is_file($filesystemPath)) {
$url .= (str_contains($url, '?') ? '&' : '?') . 'v=' . filemtime($filesystemPath);
}
return $url;
}
foreach ([
__DIR__ . '/app/Database.php',
__DIR__ . '/app/Support/View.php',
__DIR__ . '/app/Import/ImportResult.php',
__DIR__ . '/app/Import/ChunkReadFilter.php',
__DIR__ . '/app/Import/ImportJobStore.php',
__DIR__ . '/app/Import/SpreadsheetReader.php',
__DIR__ . '/app/Import/SpreadsheetRowProcessor.php',
__DIR__ . '/app/Import/ImportRepository.php',
__DIR__ . '/app/Import/ImportService.php',
__DIR__ . '/app/Http/AppController.php',
] as $file) {
require_once $file;
}