Skip to content

Commit 3f7abec

Browse files
committed
renaming
1 parent 70d0694 commit 3f7abec

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/LaravelElasticaBridgeServiceProvider.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Limenet\LaravelElasticaBridge\Commands\IndexCommand;
1212
use Limenet\LaravelElasticaBridge\Commands\StatusCommand;
1313
use Limenet\LaravelElasticaBridge\Repository\IndexRepository;
14-
use Limenet\LaravelElasticaBridge\Services\ModelEvent;
14+
use Limenet\LaravelElasticaBridge\Services\ModelEventListener;
1515
use Spatie\LaravelPackageTools\Package;
1616
use Spatie\LaravelPackageTools\PackageServiceProvider;
1717

@@ -33,7 +33,7 @@ public function configurePackage(Package $package): void
3333
public function packageRegistered(): void
3434
{
3535
$this->app->singleton(ElasticaClient::class);
36-
$this->app->bind(ModelEvent::class);
36+
$this->app->bind(ModelEventListener::class);
3737
$this->app->tag(config('elastica-bridge.indices'), 'elasticaBridgeIndices');
3838

3939
$this->app->when(IndexRepository::class)
@@ -43,16 +43,16 @@ public function packageRegistered(): void
4343

4444
public function packageBooted(): void
4545
{
46-
foreach (ModelEvent::EVENTS as $name) {
46+
foreach (ModelEventListener::EVENTS as $name) {
4747
Event::listen(
4848
sprintf('eloquent.%s:*', $name),
4949
queueable(function (string $event, array $models) use ($name): void {
5050
if (!resolve(ElasticaClient::class)->listensToEvents()) {
5151
return;
5252
}
5353

54-
$modelEvent = resolve(ModelEvent::class);
55-
collect($models)->each(fn (Model $model) => $modelEvent->handle($name, $model));
54+
$modelEventListener = resolve(ModelEventListener::class);
55+
collect($models)->each(fn (Model $model) => $modelEventListener->handle($name, $model));
5656
})->onConnection(config('elastica-bridge.connection'))
5757
);
5858
}

src/Services/ModelEvent.php renamed to src/Services/ModelEventListener.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@
1010
use Limenet\LaravelElasticaBridge\Model\ElasticsearchableInterface;
1111
use Limenet\LaravelElasticaBridge\Repository\IndexRepository;
1212

13-
class ModelEvent
13+
class ModelEventListener
1414
{
1515
public const EVENT_CREATED = 'created';
1616
public const EVENT_UPDATED = 'updated';
1717
public const EVENT_SAVED = 'saved';
1818
public const EVENT_RESTORED = 'restored';
1919
public const EVENT_DELETED = 'deleted';
2020
public const EVENTS = [
21-
self::EVENT_CREATED, self::EVENT_UPDATED, self::EVENT_SAVED, self::EVENT_RESTORED, self::EVENT_DELETED, ];
21+
self::EVENT_CREATED,
22+
self::EVENT_UPDATED,
23+
self::EVENT_SAVED,
24+
self::EVENT_RESTORED,
25+
self::EVENT_DELETED,
26+
];
2227

2328
public function __construct(protected IndexRepository $indexRepository)
2429
{

0 commit comments

Comments
 (0)