chore: complete update
This commit is contained in:
41
src/Framework/Core/Events/EventHandlerCompiler.php
Normal file
41
src/Framework/Core/Events/EventHandlerCompiler.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
|
||||
use App\Framework\Core\AttributeCompiler;
|
||||
|
||||
/**
|
||||
* Compiler für Event-Handler
|
||||
*/
|
||||
final class EventHandlerCompiler implements AttributeCompiler
|
||||
{
|
||||
/**
|
||||
* Gibt die Attributklasse zurück, die dieser Compiler verarbeitet
|
||||
*/
|
||||
public function getAttributeClass(): string
|
||||
{
|
||||
return OnEvent::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kompiliert die Event-Handler
|
||||
*
|
||||
* @param array $attributeData Array mit Attributdaten aus dem Mapper
|
||||
* @return array Kompilierte Event-Handler
|
||||
*/
|
||||
public function compile(array $attributeData): array
|
||||
{
|
||||
// Sortieren nach Priorität (höhere Werte zuerst)
|
||||
usort($attributeData, function ($a, $b) {
|
||||
$priorityA = $a['attribute']->priority ?? 0;
|
||||
$priorityB = $b['attribute']->priority ?? 0;
|
||||
|
||||
return $priorityB <=> $priorityA;
|
||||
});
|
||||
|
||||
// Weitere Kompilierung wenn nötig (z.B. Validierung)
|
||||
|
||||
return $attributeData;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user