register modules in queue
This commit is contained in:
parent
111cbb17d1
commit
244d73ec9a
|
|
@ -3,12 +3,15 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use App\Notifications\Common\ImportFailed;
|
||||
use App\Traits\Modules;
|
||||
use Illuminate\Queue\Events\JobFailed;
|
||||
use Illuminate\Queue\Events\JobProcessing;
|
||||
use Illuminate\Support\ServiceProvider as Provider;
|
||||
|
||||
class Queue extends Provider
|
||||
{
|
||||
use Modules;
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
|
|
@ -52,6 +55,8 @@ class Queue extends Provider
|
|||
}
|
||||
|
||||
$company->makeCurrent();
|
||||
|
||||
$this->registerModules();
|
||||
});
|
||||
|
||||
app('events')->listen(JobFailed::class, function ($event) {
|
||||
|
|
|
|||
|
|
@ -560,4 +560,9 @@ trait Modules
|
|||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function registerModules(): void
|
||||
{
|
||||
app(\Akaunting\Module\Contracts\ActivatorInterface::class)->register();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ class ModuleActivator implements ActivatorInterface
|
|||
{
|
||||
$this->cache = $app['cache'];
|
||||
$this->config = $app['config'];
|
||||
$this->statuses = $this->getStatuses();
|
||||
|
||||
$this->load();
|
||||
}
|
||||
|
||||
public function is(Module $module, bool $active): bool
|
||||
|
|
@ -99,7 +100,19 @@ class ModuleActivator implements ActivatorInterface
|
|||
$this->flushCache();
|
||||
}
|
||||
|
||||
public function getStatuses(): array
|
||||
public function reset(): void
|
||||
{
|
||||
$this->statuses = [];
|
||||
|
||||
$this->flushCache();
|
||||
}
|
||||
|
||||
public function load(): void
|
||||
{
|
||||
$this->statuses = $this->getStatusesByCompany();
|
||||
}
|
||||
|
||||
public function getStatusesByCompany(): array
|
||||
{
|
||||
if (! $this->config->get('module.cache.enabled')) {
|
||||
return $this->readDatabase();
|
||||
|
|
@ -146,17 +159,17 @@ class ModuleActivator implements ActivatorInterface
|
|||
return $modules;
|
||||
}
|
||||
|
||||
public function reset(): void
|
||||
{
|
||||
$this->statuses = [];
|
||||
|
||||
$this->flushCache();
|
||||
}
|
||||
|
||||
public function flushCache(): void
|
||||
{
|
||||
$key = $this->config->get('module.cache.key') . '.statuses';
|
||||
|
||||
$this->cache->forget($key);
|
||||
}
|
||||
|
||||
public function register(): void
|
||||
{
|
||||
$this->load();
|
||||
|
||||
app()->register(\Akaunting\Module\Providers\Bootstrap::class, true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,6 +179,16 @@ if (! function_exists('running_in_queue')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (! function_exists('running_in_test')) {
|
||||
/**
|
||||
* Detect if application is running in test.
|
||||
*/
|
||||
function running_in_test(): bool
|
||||
{
|
||||
return env_is_testing() && app()->runningInConsole();
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('simple_icons')) {
|
||||
/**
|
||||
* Get the simple icon content
|
||||
|
|
|
|||
Loading…
Reference in New Issue