refactored module commands
This commit is contained in:
45
app/Listeners/Module/ClearCache.php
Normal file
45
app/Listeners/Module/ClearCache.php
Normal 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');
|
||||
}
|
||||
}
|
||||
}
|
27
app/Listeners/Module/FinishInstallation.php
Normal file
27
app/Listeners/Module/FinishInstallation.php
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user