src/Prettus/Repository/Providers/EventServiceProvider.php
<?php
namespace Prettus\Repository\Providers;
use Illuminate\Support\ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event handler mappings for the application.
*
* @var array
*/
protected $listen = [
'Prettus\Repository\Events\RepositoryEntityCreated' => [
'Prettus\Repository\Listeners\CleanCacheRepository',
],
'Prettus\Repository\Events\RepositoryEntityUpdated' => [
'Prettus\Repository\Listeners\CleanCacheRepository',
],
'Prettus\Repository\Events\RepositoryEntityDeleted' => [
'Prettus\Repository\Listeners\CleanCacheRepository',
],
];
/**
* Register the application's event listeners.
*
* @return void
*/
public function boot()
{
$events = app('events');
foreach ($this->listen as $event => $listeners) {
foreach ($listeners as $listener) {
$events->listen($event, $listener);
}
}
}
/**
* {@inheritdoc}
*/
public function register()
{
//
}
/**
* Get the events and handlers.
*
* @return array
*/
public function listens()
{
return $this->listen;
}
}