Skip to content

Commit

Permalink
TASK: Optimize runtime cache for RenderingModes for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
mficzel committed Sep 16, 2023
1 parent 0463da9 commit 5639b6b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Neos.Neos/Classes/Domain/Service/RenderingModeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,20 @@ public function findDefault(): RenderingMode
*/
public function findByName(string $modeName): RenderingMode
{
return $this->instances[$modeName] ??= match (true) {
$modeName === RenderingMode::FRONTEND => RenderingMode::createFrontend(),
isset($this->editPreviewModes[$modeName]) => RenderingMode::createFromConfiguration($modeName, $this->editPreviewModes[$modeName]),
default => throw new Exception(
if ($instance = $this->instances[$modeName] ?? null) {
return $instance;
}
if ($modeName === RenderingMode::FRONTEND) {
$this->instances[$modeName] = RenderingMode::createFrontend();
} elseif (isset($this->editPreviewModes[$modeName])) {
$this->instances[$modeName] = RenderingMode::createFromConfiguration($modeName, $this->editPreviewModes[$modeName]);
} else {
throw new Exception(
'The requested rendering mode "' . $modeName . '" is not configured.'
. ' Please make sure it exists as key in the Settings path "Neos.Neos.Interface.editPreviewModes".',
1427715962
)
};
);
}
return $this->instances[$modeName];
}
}

0 comments on commit 5639b6b

Please sign in to comment.