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 9305987
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions Neos.Neos/Classes/Domain/Service/RenderingModeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,21 @@ 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(
'The requested rendering mode "' . $modeName . '" is not configured.'
. ' Please make sure it exists as key in the Settings path "Neos.Neos.Interface.editPreviewModes".',
1427715962
)
};
if ($instance = $this->instances[$modeName] ?? null) {
return $instance;
}
if ($modeName === RenderingMode::FRONTEND) {
$this->instances[$modeName] = RenderingMode::createFrontend();
} else {
if (!isset($this->editPreviewModes[$modeName])) {
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
);
}
$this->instances[$modeName] = RenderingMode::createFromConfiguration($modeName, $this->editPreviewModes[$modeName]);
}
return $this->instances[$modeName];
}
}

0 comments on commit 9305987

Please sign in to comment.