refactored module commands

This commit is contained in:
Denis Duliçi
2020-06-11 23:32:13 +03:00
parent 72cfdf14b2
commit b54c9b1ecc
16 changed files with 395 additions and 353 deletions

View File

@ -0,0 +1,45 @@
<?php
namespace App\Listeners\Module;
use Illuminate\Support\Facades\Cache;
class ClearCache
{
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle($event)
{
if (config('module.cache.enabled')) {
Cache::forget(config('module.cache.key'));
}
Cache::forget('apps.notifications');
Cache::forget('apps.suggestions');
Cache::forget('apps.installed.' . $event->company_id);
}
/**
* Register the listeners for the subscriber.
*
* @param \Illuminate\Events\Dispatcher $dispatcher
*/
public function subscribe($dispatcher)
{
$events = [
'App\Events\Install\UpdateCacheCleared',
'App\Events\Module\Copied',
'App\Events\Module\Enabled',
'App\Events\Module\Disabled',
'App\Events\Module\Uninstalled',
];
foreach ($events as $event) {
$dispatcher->listen($event, 'App\Listeners\Module\ClearCache@handle');
}
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace App\Listeners\Module;
use App\Events\Module\Installed as Event;
use App\Traits\Permissions;
use Artisan;
class FinishInstallation
{
use Permissions;
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(Event $event)
{
$module = module($event->alias);
Artisan::call('migrate', ['--force' => true]);
$this->attachDefaultModulePermissions($module);
}
}