Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
140 lines
4.3 KiB
PHP
140 lines
4.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace BladeUI\Icons;
|
|
|
|
use BladeUI\Icons\Components\Icon;
|
|
use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
|
|
use Illuminate\Contracts\View\Factory as ViewFactory;
|
|
use Illuminate\Filesystem\Filesystem;
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Support\Facades\Blade;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
final class BladeIconsServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
$this->registerConfig();
|
|
$this->registerFactory();
|
|
$this->registerManifest();
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
$this->bootCommands();
|
|
$this->bootDirectives();
|
|
$this->bootIconComponent();
|
|
$this->bootPublishing();
|
|
}
|
|
|
|
private function registerConfig(): void
|
|
{
|
|
$this->mergeConfigFrom(__DIR__.'/../config/blade-icons.php', 'blade-icons');
|
|
}
|
|
|
|
private function registerFactory(): void
|
|
{
|
|
$this->app->singleton(Factory::class, function (Application $app) {
|
|
$config = $app->make('config')->get('blade-icons', []);
|
|
|
|
$factory = new Factory(
|
|
new Filesystem,
|
|
$app->make(IconsManifest::class),
|
|
$app->make(FilesystemFactory::class),
|
|
$config,
|
|
);
|
|
|
|
foreach ($config['sets'] ?? [] as $set => $options) {
|
|
if (! isset($options['disk']) || ! $options['disk']) {
|
|
$paths = $options['paths'] ?? $options['path'] ?? [];
|
|
|
|
$options['paths'] = array_map(
|
|
fn ($path) => $app->basePath($path),
|
|
(array) $paths,
|
|
);
|
|
}
|
|
|
|
$factory->add($set, $options);
|
|
}
|
|
|
|
return $factory;
|
|
});
|
|
|
|
$this->callAfterResolving(ViewFactory::class, function ($view, Application $app) {
|
|
$app->make(Factory::class)->registerComponents();
|
|
});
|
|
|
|
// Ensure components are registered during console commands (like optimize)
|
|
// that compile views before ViewFactory is resolved. `icons:cache` is
|
|
// intentionally excluded: it only writes the manifest, so pre-registering
|
|
// every component would duplicate the filesystem scan and add thousands of
|
|
// unnecessary Blade::component() calls when large icon packs are installed.
|
|
if ($this->app->runningInConsole()) {
|
|
$this->app->booted(function (Application $app) {
|
|
if (in_array($_SERVER['argv'][1] ?? null, ['optimize', 'view:cache'])) {
|
|
try {
|
|
$app->make(Factory::class)->registerComponents();
|
|
} catch (\Exception $e) {
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
private function registerManifest(): void
|
|
{
|
|
$this->app->singleton(IconsManifest::class, function (Application $app) {
|
|
return new IconsManifest(
|
|
new Filesystem,
|
|
$this->manifestPath(),
|
|
$app->make(FilesystemFactory::class),
|
|
);
|
|
});
|
|
}
|
|
|
|
private function manifestPath(): string
|
|
{
|
|
return $this->app->bootstrapPath('cache/blade-icons.php');
|
|
}
|
|
|
|
private function bootCommands(): void
|
|
{
|
|
if ($this->app->runningInConsole()) {
|
|
$this->commands([
|
|
Console\CacheCommand::class,
|
|
Console\ClearCommand::class,
|
|
]);
|
|
|
|
if (method_exists($this, 'optimizes')) {
|
|
$this->optimizes(
|
|
'icons:cache',
|
|
'icons:clear',
|
|
'blade-icons'
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
private function bootDirectives(): void
|
|
{
|
|
Blade::directive('svg', fn ($expression) => "<?php echo e(svg($expression)); ?>");
|
|
}
|
|
|
|
private function bootIconComponent(): void
|
|
{
|
|
if ($name = config('blade-icons.components.default')) {
|
|
Blade::component($name, Icon::class);
|
|
}
|
|
}
|
|
|
|
private function bootPublishing(): void
|
|
{
|
|
if ($this->app->runningInConsole()) {
|
|
$this->publishes([
|
|
__DIR__.'/../config/blade-icons.php' => $this->app->configPath('blade-icons.php'),
|
|
], 'blade-icons');
|
|
}
|
|
}
|
|
}
|