diff --git a/app/Core/Application.php b/app/Core/Application.php index 03e0ab850..d77b5767b 100644 --- a/app/Core/Application.php +++ b/app/Core/Application.php @@ -61,6 +61,20 @@ class Application extends Container */ protected $booted = false; + /** + * The array of booting callbacks. + * + * @var callable[] + */ + protected $bootingCallbacks = []; + + /** + * The array of booted callbacks. + * + * @var callable[] + */ + protected $bootedCallbacks = []; + /** * Constructor method for the class. * @@ -81,6 +95,8 @@ public function __construct() Facade::setFacadeApplication($this); Events::discover_listeners(); + + $this->boot(); } /** * Check if application has been bootstrapped @@ -191,6 +207,8 @@ private function registerCoreAliases(): void $this->alias(HttpKernel::class, HttpKernelContract::class); $this->alias(\Illuminate\Encryption\Encrypter::class, "encrypter"); + + $this->alias(\Leantime\Core\Events::class, 'events'); } /** @@ -654,6 +672,10 @@ protected function fireAppCallbacks(array &$callbacks) } } + public function runningUnitTests() { + return false; + } + /** * Flush the container of all bindings and resolved instances. * @@ -678,4 +700,13 @@ public function flush() $this->globalResolvingCallbacks = []; $this->globalAfterResolvingCallbacks = []; } + + public function storagePath($path) { + + if($path == "framework/cache") { + $path = "cache"; + } + + return APP_ROOT."/".$path; + } } diff --git a/app/Core/ConsoleKernel.php b/app/Core/ConsoleKernel.php index 9efa5da65..6c08c269e 100644 --- a/app/Core/ConsoleKernel.php +++ b/app/Core/ConsoleKernel.php @@ -39,6 +39,7 @@ public function getArtisan(): ConsoleApplicationContract|ConsoleApplication { app()->alias(\Illuminate\Console\Application::class, ConsoleApplicationContract::class); app()->alias(\Illuminate\Console\Application::class, ConsoleApplication::class); + return $this->artisan ??= app()->instance(\Illuminate\Console\Application::class, new class extends ConsoleApplication implements ConsoleApplicationContract { /** @@ -124,6 +125,7 @@ protected function commands() $customCommands = $customPluginCommands = null; + session(["commands.core" => collect(glob(APP_ROOT . '/app/Command/*.php') ?? []) ->filter(function ($command) use (&$customCommands) { return ! Arr::has( @@ -155,6 +157,14 @@ protected function commands() * * @var LaravelCommand[]|SymfonyCommand[] $additionalCommands **/ + $glob = glob(APP_ROOT . '/vendor/illuminate/*/Console/*.php'); + $laravelCommands = collect($glob)->map(function ($command) { + $path = Str::replace(APP_ROOT."/vendor/illuminate/", "", $command); + $cleanPath = ucfirst(Str::replace(['/', '.php'], ['\\', ''], $path)); + return "Illuminate\\".$cleanPath; + }); + session(["commands.laravel" => $laravelCommands]); + $additionalCommands = self::dispatch_filter('additional_commands', [ \Illuminate\Console\Scheduling\ScheduleRunCommand::class, \Illuminate\Console\Scheduling\ScheduleFinishCommand::class, @@ -162,9 +172,10 @@ protected function commands() \Illuminate\Console\Scheduling\ScheduleTestCommand::class, \Illuminate\Console\Scheduling\ScheduleWorkCommand::class, \Illuminate\Console\Scheduling\ScheduleClearCacheCommand::class, - \Illuminate\Cache\Console\ClearCommand::class, ]); + $commands = collect($commands)->concat($laravelCommands); + collect($commands)->concat($additionalCommands) ->each(function ($command) { if ( diff --git a/app/Core/Events.php b/app/Core/Events.php index 5b65c475d..8d3950071 100644 --- a/app/Core/Events.php +++ b/app/Core/Events.php @@ -70,6 +70,14 @@ public static function dispatch_event( self::executeHandlers($matchedEvents, "events", $eventName, $payload); } + public function dispatch( + string $eventName, + mixed $payload = [], + string $context = '' + ) { + $this->dispatch_event($eventName, $payload, $context); + } + /** * Finds event listeners by event names, diff --git a/app/Core/Providers/Cache.php b/app/Core/Providers/Cache.php index a7f2f5424..353c0aae7 100644 --- a/app/Core/Providers/Cache.php +++ b/app/Core/Providers/Cache.php @@ -67,20 +67,20 @@ function () use ($instanceStore) { return $cacheManager; }); + + $this->app->singleton('cache.store', fn ($app) => $app['cache']->driver()); $this->app->singleton('cache.psr6', fn ($app) => new \Symfony\Component\Cache\Adapter\Psr16Adapter($app['cache.store'])); $this->app->singleton('memcached.connector', fn () => new MemcachedConnector()); - $this->app->alias(\Illuminate\Cache\CacheManager::class, 'cache'); $this->app->alias(\Illuminate\Cache\CacheManager::class, \Illuminate\Contracts\Cache\Factory::class); + } public function boot() { - - $currentVersion = $this->app->make(AppSettings::class)->appVersion; $cachedVersion = \Illuminate\Support\Facades\Cache::store('installation')->rememberForever('version', fn () => $currentVersion); diff --git a/app/Core/Providers/Environment.php b/app/Core/Providers/Environment.php index 5cc0ad299..c93785bcd 100644 --- a/app/Core/Providers/Environment.php +++ b/app/Core/Providers/Environment.php @@ -32,15 +32,15 @@ public function register() $this->app->alias(\Leantime\Core\Environment::class, 'config'); $this->app->alias(\Leantime\Core\Environment::class, \Illuminate\Contracts\Config\Repository::class); + } public function boot() { + $this->app->make(\Leantime\Core\AppSettings::class)->loadSettings(); $config = $this->app->make(\Leantime\Core\AppSettings::class); - - $this->setErrorHandler($config->debug ?? 0); self::dispatch_event('config_initialized'); diff --git a/app/Domain/Cron/Controllers/Run.php b/app/Domain/Cron/Controllers/Run.php index 61a504689..ba7746af1 100644 --- a/app/Domain/Cron/Controllers/Run.php +++ b/app/Domain/Cron/Controllers/Run.php @@ -56,6 +56,7 @@ public function run(): Response /** @return never **/ (new \Leantime\Core\ConsoleKernel())->call('schedule:run', [], $output); + }); return tap(new Response(), function ($response) { diff --git a/app/helpers.php b/app/helpers.php index 82a1b6b24..c76d65423 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -333,3 +333,11 @@ function session($key = null, $default = null) } } + +if (! function_exists('storage_path')) { + function storage_path($path = '') + { + return app()->storagePath($path); + } + +}