Imports classes in plugins with "use" instead of full references.
parent
1cb618d043
commit
cfed37ef8f
|
|
@ -1,5 +1,8 @@
|
|||
<?php
|
||||
|
||||
use App\App;
|
||||
use App\Core\PluginManager;
|
||||
|
||||
/**
|
||||
* Logs Plugin Bootstrap
|
||||
*
|
||||
|
|
@ -13,6 +16,24 @@ if (!defined('PLUGIN_LOGS_PATH')) {
|
|||
// Load plugin helpers
|
||||
require_once PLUGIN_LOGS_PATH . 'helpers.php';
|
||||
|
||||
if (!function_exists('logs_plugin_is_enabled')) {
|
||||
/**
|
||||
* Determine whether the logs plugin is enabled before running migrations or hooks.
|
||||
*/
|
||||
function logs_plugin_is_enabled(): bool
|
||||
{
|
||||
if (class_exists(PluginManager::class)) {
|
||||
try {
|
||||
return PluginManager::isEnabled('logs');
|
||||
} catch (\Throwable $e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Register route with callable dispatcher
|
||||
register_plugin_route_prefix('logs', [
|
||||
'dispatcher' => function($action, array $context = []) {
|
||||
|
|
@ -34,7 +55,7 @@ if (!function_exists('logs_ensure_tables')) {
|
|||
if ($ensured) {
|
||||
return;
|
||||
}
|
||||
$db = \App\App::db();
|
||||
$db = App::db();
|
||||
if (!$db || !method_exists($db, 'getConnection')) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -73,6 +94,10 @@ if (!function_exists('logs_ensure_tables')) {
|
|||
|
||||
// Logger plugin bootstrap
|
||||
register_hook('logger.system_init', function(array $context) {
|
||||
if (!logs_plugin_is_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure tables exist
|
||||
logs_ensure_tables();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use App\App;
|
||||
|
||||
/**
|
||||
* Logs Plugin Controller
|
||||
*
|
||||
|
|
@ -14,8 +16,8 @@ require_once APP_PATH . 'helpers/url_canonicalizer.php';
|
|||
|
||||
function logs_plugin_handle(string $action, array $context = []): bool {
|
||||
$validSession = (bool)($context['valid_session'] ?? false);
|
||||
$app_root = $context['app_root'] ?? (\App\App::get('app_root') ?? '/');
|
||||
$db = $context['db'] ?? \App\App::db();
|
||||
$app_root = $context['app_root'] ?? (App::get('app_root') ?? '/');
|
||||
$db = $context['db'] ?? App::db();
|
||||
$userId = $context['user_id'] ?? null;
|
||||
|
||||
if (!$db || !$userId) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
<?php
|
||||
$userTimezone = \App\App::get('user_timezone') ?: 'UTC';
|
||||
use App\App;
|
||||
|
||||
$userTimezone = App::get('user_timezone') ?: 'UTC';
|
||||
?>
|
||||
<!-- log events -->
|
||||
<div class="container-fluid mt-4">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use App\App;
|
||||
|
||||
/**
|
||||
* Register Plugin Controller
|
||||
*
|
||||
|
|
@ -17,10 +19,10 @@ require_once PLUGIN_REGISTER_PATH . 'models/register.php';
|
|||
|
||||
function register_plugin_handle_register(string $action, array $context = []): bool {
|
||||
$validSession = (bool)($context['valid_session'] ?? false);
|
||||
$app_root = $context['app_root'] ?? (\App\App::get('app_root') ?? '/');
|
||||
$config = $context['config'] ?? \App\App::config();
|
||||
$db = $context['db'] ?? \App\App::db();
|
||||
$logger = $context['logger'] ?? \App\App::get('logger');
|
||||
$app_root = $context['app_root'] ?? (App::get('app_root') ?? '/');
|
||||
$config = $context['config'] ?? App::config();
|
||||
$db = $context['db'] ?? App::db();
|
||||
$logger = $context['logger'] ?? App::get('logger');
|
||||
|
||||
if (!$db) {
|
||||
\Feedback::flash('ERROR', 'DEFAULT', 'Registration service unavailable. Please try again later.');
|
||||
|
|
|
|||
Loading…
Reference in New Issue