Skip to content

Commit

Permalink
NGSTACK-836: add strict types declaration and fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
pspanja committed May 29, 2024
1 parent 1523364 commit 4217350
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/Container/Compiler/ParentChildIndexingPass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Netgen\IbexaSearchExtra\Container\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand All @@ -26,6 +28,5 @@ public function process(ContainerBuilder $container) :void
$definition = $container->getDefinition($serviceId);
$definition->addTag(self::MessageHandlerTag);
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@

class ContentEventSubscriber implements EventSubscriberInterface
{
/**
* @var array<int, int[]>
*/
private array $parentLocationIdsByContentId = [];

public function __construct(
private readonly MessageBusInterface $messageBus,
private readonly LocationHandler $locationHandler,

private readonly LocationHandler $locationHandler,
) {}

public static function getSubscribedEvents(): array
Expand Down Expand Up @@ -60,6 +63,7 @@ public function onCopyContent(CopyContentEvent $event): void
public function onBeforeDeleteContent(BeforeDeleteContentEvent $event): void
{
$contentLocations = $this->locationHandler->loadLocationsByContent($event->getContentInfo()->id);

try {
foreach ($contentLocations as $contentLocation){
$this->parentLocationIdsByContentId[$event->getContentInfo()->id][] = $contentLocation->parentId;
Expand All @@ -78,6 +82,7 @@ public function onDeleteContent(DeleteContentEvent $event): void
$this->parentLocationIdsByContentId[$event->getContentInfo()->id] ?? [],
),
);

unset($this->parentLocationIdsByContentId[$event->getContentInfo()->id]);
}

Expand Down

0 comments on commit 4217350

Please sign in to comment.