Skip to content

Commit

Permalink
rename boolean variables for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
limenet committed Mar 27, 2024
1 parent dfcf749 commit d57ea65
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/Messenger/Message/AbstractRefresh.php
Expand Up @@ -11,16 +11,16 @@ abstract class AbstractRefresh
/** @var class-string<ElementInterface> */
public string $className;
public int $id;
private bool $stopPropagateEvents = false;
private bool $shouldStopEventPropagation = false;

public function isEventPropagationStopped(): bool
{
return $this->stopPropagateEvents;
return $this->shouldStopEventPropagation;
}

public function stopEventPropagation(): void
{
$this->stopPropagateEvents = true;
$this->setShouldStopEventPropagation(true);
}

protected function setElement(ElementInterface $element): void
Expand All @@ -29,8 +29,8 @@ protected function setElement(ElementInterface $element): void
$this->id = $element->getId() ?? throw new \InvalidArgumentException('Pimcore ID is null.');
}

protected function setPropagateEvents(bool $stopPropagateEvents): void
protected function setShouldStopEventPropagation(bool $stopEventPropagation): void
{
$this->stopPropagateEvents = $stopPropagateEvents;
$this->shouldStopEventPropagation = $stopEventPropagation;
}
}
8 changes: 5 additions & 3 deletions src/Messenger/Message/RefreshElement.php
Expand Up @@ -8,9 +8,11 @@

class RefreshElement extends AbstractRefresh
{
public function __construct(ElementInterface $element, bool $stopPropagateEvents = false)
{
public function __construct(
ElementInterface $element,
bool $stopEventPropagation = false,
) {
$this->setElement($element);
$this->setPropagateEvents($stopPropagateEvents);
$this->setShouldStopEventPropagation($stopEventPropagation);
}
}
4 changes: 2 additions & 2 deletions src/Messenger/Message/RefreshElementInIndex.php
Expand Up @@ -11,9 +11,9 @@ class RefreshElementInIndex extends AbstractRefresh
public function __construct(
ElementInterface $element,
public readonly string $index,
bool $stopPropagateEvents = false,
bool $stopEventPropagation = false,
) {
$this->setPropagateEvents($stopPropagateEvents);
$this->setShouldStopEventPropagation($stopEventPropagation);
$this->setElement($element);
}
}
14 changes: 7 additions & 7 deletions src/Service/PropagateChanges.php
Expand Up @@ -21,7 +21,7 @@

class PropagateChanges
{
private static bool $propagationStopped = false;
private static bool $isPropagationStopped = false;

public function __construct(
private readonly IndexRepository $indexRepository,
Expand All @@ -42,7 +42,7 @@ public function handle(AbstractElement $element): void

$event = new RefreshedElementEvent($element, $indices);

if (!self::$propagationStopped) {
if (!self::$isPropagationStopped) {
$this->eventDispatcher->dispatch($event, ElasticaBridgeEvents::PRE_REFRESH_ELEMENT);
}

Expand All @@ -51,12 +51,12 @@ public function handle(AbstractElement $element): void
new RefreshElementInIndex(
$element,
$index->getName(),
self::$propagationStopped || $event->isPropagationStopped()
self::$isPropagationStopped || $event->isPropagationStopped()
)
);
}

if (!self::$propagationStopped && !$event->isPropagationStopped()) {
if (!self::$isPropagationStopped && !$event->isPropagationStopped()) {
$this->eventDispatcher->dispatch($event, ElasticaBridgeEvents::POST_REFRESH_ELEMENT);
}
}
Expand All @@ -71,7 +71,7 @@ public function handleIndex(

public static function stopPropagation(): void
{
self::$propagationStopped = true;
self::$isPropagationStopped = true;
}

private function doHandleIndex(
Expand Down Expand Up @@ -109,7 +109,7 @@ private function doHandleIndex(

$event = new RefreshedElementInIndexEvent($element, $index, $elasticaIndex, $operation);

if (!self::$propagationStopped) {
if (!self::$isPropagationStopped) {
$this->eventDispatcher->dispatch($event, ElasticaBridgeEvents::PRE_REFRESH_ELEMENT_IN_INDEX);
}

Expand All @@ -120,7 +120,7 @@ private function doHandleIndex(
ElementInIndexOperation::NOTHING => null,
};

if (!self::$propagationStopped && !$event->isPropagationStopped()) {
if (!self::$isPropagationStopped && !$event->isPropagationStopped()) {
$this->eventDispatcher->dispatch($event, ElasticaBridgeEvents::POST_REFRESH_ELEMENT_IN_INDEX);
}

Expand Down

0 comments on commit d57ea65

Please sign in to comment.