Fixes regarding to init.php

This commit is contained in:
slawkens 2024-11-08 10:23:22 +01:00
parent c3dd10af96
commit 92024cfdbf
12 changed files with 21 additions and 11 deletions

6
aac
View File

@ -9,14 +9,13 @@ if(!IS_CLI) {
} }
require_once SYSTEM . 'functions.php'; require_once SYSTEM . 'functions.php';
require_once SYSTEM . 'init.php';
define('SELF_NAME', basename(__FILE__)); define('SELF_NAME', basename(__FILE__));
use MyAAC\Plugins; use MyAAC\Plugins;
use Symfony\Component\Console\Application; use Symfony\Component\Console\Application;
$application = new Application(); $application = new Application('MyAAC', MYAAC_VERSION);
$commandsGlob = glob(SYSTEM . 'src/Commands/*.php'); $commandsGlob = glob(SYSTEM . 'src/Commands/*.php');
foreach ($commandsGlob as $item) { foreach ($commandsGlob as $item) {
@ -34,7 +33,4 @@ foreach ($pluginCommands as $item) {
$application->add(require $item); $application->add(require $item);
} }
$application->setName('MyAAC');
$application->setVersion(MYAAC_VERSION);
$application->run(); $application->run();

View File

@ -14,10 +14,10 @@ use MyAAC\CsrfToken;
use MyAAC\Hooks; use MyAAC\Hooks;
use MyAAC\Models\Town; use MyAAC\Models\Town;
use MyAAC\Settings; use MyAAC\Settings;
use MyAAC\Towns;
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
global $config;
if(!isset($config['installed']) || !$config['installed']) { if(!isset($config['installed']) || !$config['installed']) {
throw new RuntimeException('MyAAC has not been installed yet or there was error during installation. Please install again.'); throw new RuntimeException('MyAAC has not been installed yet or there was error during installation. Please install again.');
} }
@ -46,6 +46,7 @@ if(isset($config['gzip_output']) && $config['gzip_output'] && isset($_SERVER['HT
$cache = Cache::getInstance(); $cache = Cache::getInstance();
// event system // event system
global $hooks;
$hooks = new Hooks(); $hooks = new Hooks();
$hooks->load(); $hooks->load();

View File

@ -16,6 +16,8 @@ class CacheClearCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
require SYSTEM . 'init.php';
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
if (!clearCache()) { if (!clearCache()) {

View File

@ -2,12 +2,8 @@
namespace MyAAC\Commands; namespace MyAAC\Commands;
use MyAAC\Hooks;
use Symfony\Component\Console\Command\Command as SymfonyCommand; use Symfony\Component\Console\Command\Command as SymfonyCommand;
class Command extends SymfonyCommand class Command extends SymfonyCommand
{ {
public function __construct() {
parent::__construct();
}
} }

View File

@ -16,10 +16,11 @@ class CronjobCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
require SYSTEM . 'init.php';
// Create a new scheduler // Create a new scheduler
$scheduler = new Scheduler(); $scheduler = new Scheduler();
global $hooks;
$hooks->trigger(HOOK_CRONJOB, ['scheduler' => $scheduler]); $hooks->trigger(HOOK_CRONJOB, ['scheduler' => $scheduler]);
// Let the scheduler execute jobs which are due. // Let the scheduler execute jobs which are due.

View File

@ -17,6 +17,8 @@ class CronjobInstallCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
require SYSTEM . 'init.php';
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
if (MYAAC_OS !== 'LINUX') { if (MYAAC_OS !== 'LINUX') {

View File

@ -21,6 +21,8 @@ class MailSendCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
require SYSTEM . 'init.php';
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
if (!setting('core.mail_enabled')) { if (!setting('core.mail_enabled')) {

View File

@ -21,6 +21,8 @@ class MigrateRunCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
require SYSTEM . 'init.php';
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
$ids = $input->getArgument('id'); $ids = $input->getArgument('id');

View File

@ -19,6 +19,8 @@ class PluginInstallCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
require SYSTEM . 'init.php';
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
$pathToFile = $input->getArgument('plugin'); $pathToFile = $input->getArgument('plugin');

View File

@ -19,6 +19,8 @@ class PluginInstallInstallCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
require SYSTEM . 'init.php';
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
$pluginName = $input->getArgument('plugin'); $pluginName = $input->getArgument('plugin');

View File

@ -19,6 +19,8 @@ class SettingsResetCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
require SYSTEM . 'init.php';
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
if (!$io->confirm('Are you sure you want to reset all settings in database?', false)) { if (!$io->confirm('Are you sure you want to reset all settings in database?', false)) {

View File

@ -27,6 +27,8 @@ class SettingsSetCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
require SYSTEM . 'init.php';
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);
$key = $input->getArgument('key'); $key = $input->getArgument('key');