Skip to content

Commit

Permalink
[News] fix visibility check (#11361)
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano authored Jan 24, 2025
1 parent d949fa5 commit 49fe18b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/Entity/EntityScopeVisibilityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ public function getZone(): ?Zone

public function setZone(?Zone $zone): void
{
$this->visibility = null !== $zone
? ScopeVisibilityEnum::LOCAL
: ScopeVisibilityEnum::NATIONAL;

$this->zone = $zone;
$this->visibility = $zone && !$zone->isFrance() ? ScopeVisibilityEnum::LOCAL : ScopeVisibilityEnum::NATIONAL;
}

public function getVisibility(): string
Expand Down
5 changes: 5 additions & 0 deletions src/Entity/Geo/Zone.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,9 @@ public function isAssemblyZone(): bool
{
return $this->hasTag(ZoneTagEnum::ASSEMBLY);
}

public function isFrance(): bool
{
return AddressInterface::FRANCE === $this->code;
}
}
6 changes: 4 additions & 2 deletions src/Entity/Jecoute/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ public function setEnriched(bool $enriched): void
public function setZone(?Zone $zone): void
{
$this->traitSetZone($zone);
$this->visibility = $this->zone || $this->committee ? ScopeVisibilityEnum::LOCAL : $this->visibility;
$this->updateVisibility();
}

public function getIndexOptions(): array
Expand All @@ -358,7 +358,9 @@ public function getFieldContainingDocuments(): string

public function updateVisibility(): void
{
$this->visibility = $this->zone || $this->committee ? ScopeVisibilityEnum::LOCAL : $this->visibility;
if ($this->isNationalVisibility() && $this->committee) {
$this->visibility = ScopeVisibilityEnum::LOCAL;
}
}

public function getCommittee(): ?Committee
Expand Down

0 comments on commit 49fe18b

Please sign in to comment.