72 lines
2.4 KiB
PHP
72 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
class GenerateDomainFavicons extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'domains:generate-favicons';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Generiere Favicons für alle konfigurierten Domains';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$domains = config('domains');
|
|
$faviconDir = public_path('img/favicons');
|
|
|
|
// Erstelle das Favicon-Verzeichnis, wenn es nicht existiert
|
|
if (!File::exists($faviconDir)) {
|
|
File::makeDirectory($faviconDir, 0755, true);
|
|
$this->info("Verzeichnis {$faviconDir} erstellt.");
|
|
}
|
|
|
|
// Erstelle eine Liste der Themes, für die wir Favicons erstellen müssen
|
|
$themes = [];
|
|
|
|
foreach ($domains as $domain => $config) {
|
|
if (is_array($config) && isset($config['theme'])) {
|
|
$themes[$config['theme']] = [
|
|
'domain' => $domain,
|
|
'name' => $config['name'] ?? 'Website',
|
|
'color' => $config['color_scheme']['primary'] ?? '#000000',
|
|
];
|
|
}
|
|
}
|
|
|
|
// Erstelle die Favicons
|
|
foreach ($themes as $theme => $data) {
|
|
$faviconPath = "{$faviconDir}/{$theme}-favicon.ico";
|
|
|
|
// Wenn die Datei bereits existiert, frage, ob sie überschrieben werden soll
|
|
if (File::exists($faviconPath) && !$this->confirm("Favicon für '{$theme}' existiert bereits. Überschreiben?")) {
|
|
$this->info("Favicon für '{$theme}' übersprungen.");
|
|
continue;
|
|
}
|
|
|
|
// Hier könntest du mit einer externen Bibliothek einen Favicon erstellen
|
|
// Da dies aber komplex sein kann, erstellen wir erstmal nur Platzhalter-Dateien
|
|
File::put($faviconPath, '');
|
|
|
|
$this->info("Platzhalter-Favicon für '{$theme}' erstellt: {$faviconPath}");
|
|
$this->comment("Ersetze diese Datei mit einem echten Favicon für {$data['domain']} ({$data['name']})");
|
|
}
|
|
|
|
$this->info('Favicons wurden erfolgreich erstellt!');
|
|
$this->line('Denke daran, die Platzhalter-Dateien mit echten Favicons zu ersetzen.');
|
|
}
|
|
}
|