mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
impoort stuff!
This commit is contained in:
@@ -89,11 +89,11 @@ $container->set('view', function () use ($container) {
|
||||
case 'admin.index':
|
||||
$basePath = '/admin';
|
||||
break;
|
||||
case 'admin.settings':
|
||||
$basePath = '/admin/settings';
|
||||
case 'admin.playnite.import':
|
||||
$basePath = '/admin/playnite/import';
|
||||
break;
|
||||
case 'admin.sources':
|
||||
$basePath = '/admin/sources';
|
||||
case 'admin.playnite.upload':
|
||||
$basePath = '/admin/playnite/import';
|
||||
break;
|
||||
case 'admin.sync':
|
||||
$basePath = '/admin/sync/' . ($data['id'] ?? '');
|
||||
@@ -182,6 +182,21 @@ $container->set('view', function () use ($container) {
|
||||
return $decoded === null ? null : $decoded;
|
||||
}));
|
||||
|
||||
$twig->getEnvironment()->addFilter(new TwigFilter('filesizeformat', function ($bytes) {
|
||||
if (!$bytes || !is_numeric($bytes)) {
|
||||
return '0 B';
|
||||
}
|
||||
|
||||
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
$bytes = max($bytes, 0);
|
||||
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
||||
$pow = min($pow, count($units) - 1);
|
||||
|
||||
$bytes /= pow(1024, $pow);
|
||||
|
||||
return round($bytes, 2) . ' ' . $units[$pow];
|
||||
}));
|
||||
|
||||
return $twig;
|
||||
});
|
||||
|
||||
@@ -248,6 +263,20 @@ $container->set(\App\Controllers\SettingsController::class, function ($c) {
|
||||
return new \App\Controllers\SettingsController($c->get(PDO::class), $c->get('view'));
|
||||
});
|
||||
|
||||
// Register PlayniteImportController
|
||||
$container->set(\App\Controllers\PlayniteImportController::class, function ($c) {
|
||||
return new \App\Controllers\PlayniteImportController(
|
||||
$c->get(PDO::class),
|
||||
$c->get('view'),
|
||||
$c->get(\App\Services\AuthService::class)
|
||||
);
|
||||
});
|
||||
|
||||
// Register PlayniteImportService
|
||||
$container->set(\App\Services\PlayniteImportService::class, function ($c) {
|
||||
return new \App\Services\PlayniteImportService($c->get(PDO::class));
|
||||
});
|
||||
|
||||
// Register middleware
|
||||
$container->set(\App\Http\Middleware\AuthMiddleware::class, function ($c) {
|
||||
return new \App\Http\Middleware\AuthMiddleware($c->get(\App\Services\AuthService::class));
|
||||
|
||||
Reference in New Issue
Block a user