feca-mailshots-plugin/feca_mailshots_plugin/src/autoload.php

29 lines
850 B
PHP

<?php
declare(strict_types=1);
// Load Composer dependencies (Twig, Dompdf, etc.) when available.
$autoloadCandidates = [
dirname(__DIR__) . '/vendor/autoload.php', // Preferred: packaged/deployed plugin-local vendor
dirname(__DIR__, 2) . '/vendor/autoload.php', // Backward-compatible: workspace/shared vendor
];
foreach ($autoloadCandidates as $composerAutoload) {
if (is_file($composerAutoload)) {
require_once $composerAutoload;
break;
}
}
spl_autoload_register(static function (string $class): void {
$prefix = 'FecaMailshots\\';
if (strncmp($class, $prefix, strlen($prefix)) !== 0) {
return;
}
$relative = substr($class, strlen($prefix));
$path = __DIR__ . '/' . str_replace('\\', '/', $relative) . '.php';
if (is_file($path)) {
require_once $path;
}
});