2023-10-02 23:10:49 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Lucent;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Routing\Router;
|
2024-08-14 22:04:34 +03:00
|
|
|
use Illuminate\Support\Facades\Blade;
|
2023-10-02 23:10:49 +03:00
|
|
|
use Illuminate\Support\Facades\View;
|
2023-10-02 23:47:01 +03:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2023-10-04 13:32:30 +03:00
|
|
|
use Intervention\Image\ImageManager;
|
2023-10-02 23:10:49 +03:00
|
|
|
use Lucent\Channel\ChannelService;
|
2023-10-06 13:07:09 +03:00
|
|
|
use Lucent\Commands\CompileSchemas;
|
2024-09-07 00:03:11 +03:00
|
|
|
use Lucent\Commands\GenerateCollectionSchema;
|
|
|
|
|
use Lucent\Commands\GenerateFileSchema;
|
2023-10-16 15:38:25 +03:00
|
|
|
use Lucent\Commands\LiveLink;
|
2023-10-02 23:10:49 +03:00
|
|
|
use Lucent\Commands\RebuildThumbnails;
|
2023-11-29 17:10:15 +02:00
|
|
|
use Lucent\Commands\RemoveOrphanEdges;
|
2024-09-06 23:30:12 +03:00
|
|
|
use Lucent\Commands\SetupDatabase;
|
2024-09-27 16:27:37 +03:00
|
|
|
use Lucent\Commands\UpgradeFiles122;
|
2023-10-04 13:32:30 +03:00
|
|
|
use Lucent\File\FileService;
|
2023-10-02 23:10:49 +03:00
|
|
|
use Lucent\File\ImageService;
|
2023-10-15 23:40:34 +03:00
|
|
|
use Lucent\Query\DatabaseGraph\DatabaseGraph;
|
|
|
|
|
use Lucent\Query\DatabaseGraph\PgsqlDatabaseGraph;
|
|
|
|
|
use Lucent\Query\DatabaseGraph\SqliteDatabaseGraph;
|
2023-10-02 23:10:49 +03:00
|
|
|
|
2023-10-02 23:47:01 +03:00
|
|
|
class LucentServiceProvider extends ServiceProvider
|
2023-10-02 23:10:49 +03:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Register any application services.
|
|
|
|
|
*/
|
|
|
|
|
public function register(): void
|
|
|
|
|
{
|
|
|
|
|
$this->app->singleton(ChannelService::class, function () {
|
|
|
|
|
return ChannelService::fromConfig();
|
|
|
|
|
});
|
|
|
|
|
|
2023-10-04 13:32:30 +03:00
|
|
|
$this->app->bind(ImageManager::class, function () {
|
|
|
|
|
return new ImageManager(['driver' => 'imagick']);
|
|
|
|
|
});
|
|
|
|
|
|
2024-08-27 17:42:06 +03:00
|
|
|
|
|
|
|
|
|
2023-10-15 23:40:34 +03:00
|
|
|
$this->app->bind(DatabaseGraph::class, function () {
|
2024-08-27 17:42:06 +03:00
|
|
|
$dbConnection = config("lucent.database");
|
|
|
|
|
return match (config("database.connections.$dbConnection.driver")) {
|
2023-10-15 23:40:34 +03:00
|
|
|
"sqlite" => new SqliteDatabaseGraph(),
|
|
|
|
|
"pgsql" => new PgsqlDatabaseGraph(),
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2024-08-19 17:48:10 +03:00
|
|
|
|
2023-10-04 13:32:30 +03:00
|
|
|
|
2023-10-02 23:10:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Bootstrap any package services.
|
|
|
|
|
*/
|
|
|
|
|
public function boot(Router $router): void
|
|
|
|
|
{
|
|
|
|
|
|
2023-10-06 13:07:09 +03:00
|
|
|
$manifestPath = public_path('vendor/lucent/dist/manifest.json');
|
2023-10-15 23:40:34 +03:00
|
|
|
$manifest = null;
|
|
|
|
|
if (file_exists($manifestPath)) {
|
|
|
|
|
$manifest = json_decode(file_get_contents(public_path('vendor/lucent/dist/manifest.json')), true);
|
2023-10-06 13:07:09 +03:00
|
|
|
}
|
|
|
|
|
|
2023-10-05 13:16:23 +03:00
|
|
|
|
2023-10-02 23:10:49 +03:00
|
|
|
$router->aliasMiddleware('lucent.auth', \Lucent\Http\Middleware\AuthMiddleware::class);
|
|
|
|
|
$router->aliasMiddleware('lucent.guest', \Lucent\Http\Middleware\GuestMiddleware::class);
|
|
|
|
|
|
2024-08-14 22:04:34 +03:00
|
|
|
$this->loadViewsFrom(__DIR__ . '/../front/views', 'lucent');
|
2023-10-02 23:10:49 +03:00
|
|
|
$this->loadRoutesFrom(__DIR__ . '/Http/web.php');
|
|
|
|
|
$this->loadRoutesFrom(__DIR__ . '/Http/api.php');
|
|
|
|
|
|
|
|
|
|
if ($this->app->runningInConsole()) {
|
|
|
|
|
$this->commands([
|
2023-10-06 13:07:09 +03:00
|
|
|
CompileSchemas::class,
|
2023-10-02 23:10:49 +03:00
|
|
|
RebuildThumbnails::class,
|
2023-10-16 15:38:25 +03:00
|
|
|
LiveLink::class,
|
2023-11-29 17:10:15 +02:00
|
|
|
RemoveOrphanEdges::class,
|
2024-09-06 23:30:12 +03:00
|
|
|
SetupDatabase::class,
|
2024-09-07 00:03:11 +03:00
|
|
|
GenerateCollectionSchema::class,
|
|
|
|
|
GenerateFileSchema::class,
|
2024-09-27 16:27:37 +03:00
|
|
|
UpgradeFiles122::class,
|
2023-10-02 23:10:49 +03:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-05 13:16:23 +03:00
|
|
|
View::share('manifest', $manifest);
|
2023-10-04 13:32:30 +03:00
|
|
|
View::share('file', app()->make(FileService::class));
|
2024-08-19 17:48:10 +03:00
|
|
|
Blade::anonymousComponentPath(__DIR__ . '../front/views/components', "lucent");
|
2023-10-02 23:10:49 +03:00
|
|
|
|
|
|
|
|
$this->publishes([
|
|
|
|
|
__DIR__ . '/Config/main.php' => config_path('lucent.php'),
|
2024-09-06 20:59:56 +03:00
|
|
|
],"lucent-config");
|
2023-10-05 13:16:23 +03:00
|
|
|
|
|
|
|
|
$this->publishes([
|
2023-10-15 23:40:34 +03:00
|
|
|
__DIR__ . '/../front/dist' => public_path('vendor/lucent/dist'),
|
2024-08-14 22:04:34 +03:00
|
|
|
__DIR__ . '/../front/public' => public_path('vendor/lucent/public'),
|
2023-10-23 18:49:47 +03:00
|
|
|
], 'lucent');
|
2024-08-19 17:48:10 +03:00
|
|
|
|
|
|
|
|
|
2023-10-02 23:10:49 +03:00
|
|
|
}
|
|
|
|
|
}
|