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