Refactor to use plugin system for language support Remove hardcoded language features from core Move language handling to plugin system Improve content file discovery Simplify context creation Add plugin system documentation Implement hook system for extensibility Add template variable hook Add context storage for plugins Improve error handling Refactor rendering logic Improve list view sorting Add support for custom list templates Improve metadata handling Add plugin system reference documentation
24 lines
668 B
PHP
24 lines
668 B
PHP
<?php
|
|
enum Hook: string {
|
|
case CONTEXT_READY = 'context_ready';
|
|
case PROCESS_CONTENT = 'process_content';
|
|
case TEMPLATE_VARS = 'template_vars';
|
|
}
|
|
|
|
class Hooks {
|
|
private static array $filters = [];
|
|
|
|
public static function add(Hook $hook, callable $callback): void {
|
|
self::$filters[$hook->value][] = $callback;
|
|
}
|
|
|
|
public static function apply(Hook $hook, mixed $value, mixed ...$args): mixed {
|
|
if (!isset(self::$filters[$hook->value])) return $value;
|
|
|
|
foreach (self::$filters[$hook->value] as $filter) {
|
|
$value = $filter($value, ...$args);
|
|
}
|
|
|
|
return $value;
|
|
}
|
|
}
|