diff --git a/aac b/aac index d87042f8..d4ce7b7d 100644 --- a/aac +++ b/aac @@ -9,14 +9,13 @@ if(!IS_CLI) { } require_once SYSTEM . 'functions.php'; -require_once SYSTEM . 'init.php'; define('SELF_NAME', basename(__FILE__)); use MyAAC\Plugins; use Symfony\Component\Console\Application; -$application = new Application(); +$application = new Application('MyAAC', MYAAC_VERSION); $commandsGlob = glob(SYSTEM . 'src/Commands/*.php'); foreach ($commandsGlob as $item) { @@ -34,7 +33,4 @@ foreach ($pluginCommands as $item) { $application->add(require $item); } -$application->setName('MyAAC'); -$application->setVersion(MYAAC_VERSION); - $application->run(); diff --git a/system/init.php b/system/init.php index dbc9db08..81ce3bbf 100644 --- a/system/init.php +++ b/system/init.php @@ -14,10 +14,10 @@ use MyAAC\CsrfToken; use MyAAC\Hooks; use MyAAC\Models\Town; use MyAAC\Settings; -use MyAAC\Towns; defined('MYAAC') or die('Direct access not allowed!'); +global $config; if(!isset($config['installed']) || !$config['installed']) { 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(); // event system +global $hooks; $hooks = new Hooks(); $hooks->load(); diff --git a/system/src/Commands/CacheClearCommand.php b/system/src/Commands/CacheClearCommand.php index bdab1f21..ff4d5d4a 100644 --- a/system/src/Commands/CacheClearCommand.php +++ b/system/src/Commands/CacheClearCommand.php @@ -16,6 +16,8 @@ class CacheClearCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { + require SYSTEM . 'init.php'; + $io = new SymfonyStyle($input, $output); if (!clearCache()) { diff --git a/system/src/Commands/Command.php b/system/src/Commands/Command.php index 76f3810e..caa2c0d3 100644 --- a/system/src/Commands/Command.php +++ b/system/src/Commands/Command.php @@ -2,12 +2,8 @@ namespace MyAAC\Commands; -use MyAAC\Hooks; use Symfony\Component\Console\Command\Command as SymfonyCommand; class Command extends SymfonyCommand { - public function __construct() { - parent::__construct(); - } } diff --git a/system/src/Commands/CronjobCommand.php b/system/src/Commands/CronjobCommand.php index f314b73b..b5eb475a 100644 --- a/system/src/Commands/CronjobCommand.php +++ b/system/src/Commands/CronjobCommand.php @@ -16,10 +16,11 @@ class CronjobCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { + require SYSTEM . 'init.php'; + // Create a new scheduler $scheduler = new Scheduler(); - global $hooks; $hooks->trigger(HOOK_CRONJOB, ['scheduler' => $scheduler]); // Let the scheduler execute jobs which are due. diff --git a/system/src/Commands/CronjobInstallCommand.php b/system/src/Commands/CronjobInstallCommand.php index adcf8b20..d6b9ee60 100644 --- a/system/src/Commands/CronjobInstallCommand.php +++ b/system/src/Commands/CronjobInstallCommand.php @@ -17,6 +17,8 @@ class CronjobInstallCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { + require SYSTEM . 'init.php'; + $io = new SymfonyStyle($input, $output); if (MYAAC_OS !== 'LINUX') { diff --git a/system/src/Commands/MailSendCommand.php b/system/src/Commands/MailSendCommand.php index 35c00713..ff1450e6 100644 --- a/system/src/Commands/MailSendCommand.php +++ b/system/src/Commands/MailSendCommand.php @@ -21,6 +21,8 @@ class MailSendCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { + require SYSTEM . 'init.php'; + $io = new SymfonyStyle($input, $output); if (!setting('core.mail_enabled')) { diff --git a/system/src/Commands/MigrateRunCommand.php b/system/src/Commands/MigrateRunCommand.php index ee0265b3..edfa108d 100644 --- a/system/src/Commands/MigrateRunCommand.php +++ b/system/src/Commands/MigrateRunCommand.php @@ -21,6 +21,8 @@ class MigrateRunCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { + require SYSTEM . 'init.php'; + $io = new SymfonyStyle($input, $output); $ids = $input->getArgument('id'); diff --git a/system/src/Commands/PluginInstallCommand.php b/system/src/Commands/PluginInstallCommand.php index f40961e7..f5504cb6 100644 --- a/system/src/Commands/PluginInstallCommand.php +++ b/system/src/Commands/PluginInstallCommand.php @@ -19,6 +19,8 @@ class PluginInstallCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { + require SYSTEM . 'init.php'; + $io = new SymfonyStyle($input, $output); $pathToFile = $input->getArgument('plugin'); diff --git a/system/src/Commands/PluginInstallInstallCommand.php b/system/src/Commands/PluginInstallInstallCommand.php index 5f1a1cd6..fe1b4f14 100644 --- a/system/src/Commands/PluginInstallInstallCommand.php +++ b/system/src/Commands/PluginInstallInstallCommand.php @@ -19,6 +19,8 @@ class PluginInstallInstallCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { + require SYSTEM . 'init.php'; + $io = new SymfonyStyle($input, $output); $pluginName = $input->getArgument('plugin'); diff --git a/system/src/Commands/SettingsResetCommand.php b/system/src/Commands/SettingsResetCommand.php index a495edf4..69473848 100644 --- a/system/src/Commands/SettingsResetCommand.php +++ b/system/src/Commands/SettingsResetCommand.php @@ -19,6 +19,8 @@ class SettingsResetCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { + require SYSTEM . 'init.php'; + $io = new SymfonyStyle($input, $output); if (!$io->confirm('Are you sure you want to reset all settings in database?', false)) { diff --git a/system/src/Commands/SettingsSetCommand.php b/system/src/Commands/SettingsSetCommand.php index 1159689a..4ad33227 100644 --- a/system/src/Commands/SettingsSetCommand.php +++ b/system/src/Commands/SettingsSetCommand.php @@ -27,6 +27,8 @@ class SettingsSetCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): int { + require SYSTEM . 'init.php'; + $io = new SymfonyStyle($input, $output); $key = $input->getArgument('key');