Skip to content

Commit

Permalink
BUGFIX: Simplify projectionState to be more reliable
Browse files Browse the repository at this point in the history
Previously if called with `ProjectionStateInterface::class` it would return the first state which will then not be callable again by its fqn. Now only fqn are allowed.
Initially the interface logic was needed for interchangeable cr readmodel projection states
  • Loading branch information
mhsdesign committed Oct 2, 2024
1 parent 701e2a1 commit a39c50e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Neos.ContentRepository.Core/Classes/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,17 @@ public function handle(CommandInterface $command): CommandResult
*/
public function projectionState(string $projectionStateClassName): ProjectionStateInterface
{
if (!isset($this->projectionStateCache)) {
foreach ($this->projectionsAndCatchUpHooks->additionalProjections as $projection) {
$projectionState = $projection->getState();
$this->projectionStateCache[$projectionState::class] = $projectionState;
}
}
if (isset($this->projectionStateCache[$projectionStateClassName])) {
/** @var T $projectionState */
$projectionState = $this->projectionStateCache[$projectionStateClassName];
return $projectionState;
}
foreach ($this->projectionsAndCatchUpHooks->additionalProjections as $projection) {
$projectionState = $projection->getState();
if ($projectionState instanceof $projectionStateClassName) {
$this->projectionStateCache[$projectionStateClassName] = $projectionState;
return $projectionState;
}
}
throw new \InvalidArgumentException(sprintf('A projection state of type "%s" is not registered in this content repository instance.', $projectionStateClassName), 1662033650);
}

Expand Down

0 comments on commit a39c50e

Please sign in to comment.