- Plugins nach WordPress-Prinzip: plugin.json-Manifest mit Versions- und Abhängigkeitsprüfung, eigenes PSR-4-Autoloading, register()/boot(), activate()/deactivate()/uninstall(), Migrationen, Routen und Views je Plugin - plugins-core/ (mitgeliefert, aktiv bis zur Deaktivierung) und plugins/ (Kunden-Plugins, geschützt vor Updates, inaktiv bis zur Aktivierung) - Zustand in storage/app/plugins.json – Laden ohne Datenbankabfrage - Wiederherstellungsmodus: Ausnahmen und Fatal Errors beim Laden deaktivieren das Plugin, das Portal bleibt erreichbar - Hooks (Actions/Filter mit Prioritäten) und Registries für Navigation, Startseiten-Kacheln, Rechte und Admin-Seiten (Filament-Discovery) - Admin-Seite „Plugins“: aktivieren, deaktivieren, per ZIP installieren (ZIP-Slip-Schutz), löschen mit oder ohne Daten; abschaltbar per INHAUS_DISALLOW_FILE_MODS - Startseite komplett aus Kacheln; Plugin-Seiten als „slug::Seite“ - Version 0.3.0 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
74 lines
1.9 KiB
PHP
74 lines
1.9 KiB
PHP
<?php
|
||
|
||
namespace App\Support\Update;
|
||
|
||
use FilesystemIterator;
|
||
use RecursiveDirectoryIterator;
|
||
use RecursiveIteratorIterator;
|
||
|
||
final class Filesystem
|
||
{
|
||
/**
|
||
* Verzeichnis verschieben – per rename(), bei Dateisystemgrenzen per Kopie.
|
||
*/
|
||
public static function moveDirectory(string $from, string $to): bool
|
||
{
|
||
if (@rename($from, $to)) {
|
||
return true;
|
||
}
|
||
|
||
if (! self::copyDirectory($from, $to)) {
|
||
self::deleteDirectory($to);
|
||
|
||
return false;
|
||
}
|
||
|
||
self::deleteDirectory($from);
|
||
|
||
return true;
|
||
}
|
||
|
||
public static function copyDirectory(string $from, string $to): bool
|
||
{
|
||
if (! is_dir($to) && ! @mkdir($to, 0775, true)) {
|
||
return false;
|
||
}
|
||
|
||
$items = new RecursiveIteratorIterator(
|
||
new RecursiveDirectoryIterator($from, FilesystemIterator::SKIP_DOTS),
|
||
RecursiveIteratorIterator::SELF_FIRST,
|
||
);
|
||
|
||
foreach ($items as $item) {
|
||
$target = $to.'/'.substr($item->getPathname(), strlen(rtrim($from, '/')) + 1);
|
||
|
||
if ($item->isDir()) {
|
||
if (! is_dir($target) && ! @mkdir($target, 0775, true)) {
|
||
return false;
|
||
}
|
||
} elseif (! @copy($item->getPathname(), $target)) {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
public static function deleteDirectory(string $dir): void
|
||
{
|
||
if (! is_dir($dir)) {
|
||
return;
|
||
}
|
||
|
||
$items = new RecursiveIteratorIterator(
|
||
new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS),
|
||
RecursiveIteratorIterator::CHILD_FIRST,
|
||
);
|
||
|
||
foreach ($items as $item) {
|
||
$item->isDir() && ! $item->isLink() ? @rmdir($item->getPathname()) : @unlink($item->getPathname());
|
||
}
|
||
|
||
@rmdir($dir);
|
||
}
|
||
}
|