From a5c1d6f9707c149be59c5f39f37e397c5960e67e Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 6 Feb 2024 10:08:33 +0100 Subject: [PATCH 1/6] TASK: Remove `Neos.Ui.Api.emptyArrayToObject` helper --- Classes/Fusion/Helper/ApiHelper.php | 43 ------------------- .../Fusion/Helper/ContentDimensionsHelper.php | 8 ++-- Configuration/Settings.yaml | 5 +-- 3 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 Classes/Fusion/Helper/ApiHelper.php diff --git a/Classes/Fusion/Helper/ApiHelper.php b/Classes/Fusion/Helper/ApiHelper.php deleted file mode 100644 index 3cc9ea0d7c..0000000000 --- a/Classes/Fusion/Helper/ApiHelper.php +++ /dev/null @@ -1,43 +0,0 @@ - $array Associative array which may be empty - * @return array|\stdClass Non-empty associative array or empty object - */ - public function emptyArrayToObject(array $array): array|object - { - return $array === [] ? new \stdClass() : $array; - } - - /** - * @param string $methodName - * @return bool - */ - public function allowsCallOfMethod($methodName) : bool - { - return true; - } -} diff --git a/Classes/Fusion/Helper/ContentDimensionsHelper.php b/Classes/Fusion/Helper/ContentDimensionsHelper.php index 3762102205..ad7ab61316 100644 --- a/Classes/Fusion/Helper/ContentDimensionsHelper.php +++ b/Classes/Fusion/Helper/ContentDimensionsHelper.php @@ -69,10 +69,9 @@ public function contentDimensionsByName(ContentRepositoryId $contentRepositoryId /** * @param DimensionSpacePoint $dimensions Dimension values indexed by dimension name - * @return array> Allowed preset names for the given dimension combination - * indexed by dimension name + * @return array>|object Allowed preset names for the given dimension combination indexed by dimension name */ - public function allowedPresetsByName(DimensionSpacePoint $dimensions, ContentRepositoryId $contentRepositoryId): array + public function allowedPresetsByName(DimensionSpacePoint $dimensions, ContentRepositoryId $contentRepositoryId): array|object { $contentDimensionHelperInternals = $this->contentRepositoryRegistry->buildService($contentRepositoryId, new ContentDimensionsHelperInternalsFactory()); $contentDimensionSource = $contentDimensionHelperInternals->contentDimensionSource; @@ -89,7 +88,8 @@ public function allowedPresetsByName(DimensionSpacePoint $dimensions, ContentRep } } - return $allowedPresets; + /** empty arrays must be rendered as `{}` in json for our client code to work */ + return $allowedPresets === [] ? new \stdClass() : $allowedPresets; } /** @return array> */ diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index ba49aef7b5..4d145e8fbf 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -99,7 +99,6 @@ Neos: content: 'Neos.Neos:Content' contentCollection: 'Neos.Neos:ContentCollection' configurationDefaultEelContext: - Neos.Ui.Api: Neos\Neos\Ui\Fusion\Helper\ApiHelper Neos.Ui.Workspace: Neos\Neos\Ui\Fusion\Helper\WorkspaceHelper Neos.Ui.NodeInfo: Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper Neos.Ui.ContentDimensions: Neos\Neos\Ui\Fusion\Helper\ContentDimensionsHelper @@ -112,7 +111,7 @@ Neos: previewUrl: '${Neos.Ui.NodeInfo.createRedirectToNode(documentNode, request)}' contentDimensions: active: '${Neos.Ui.ContentDimensions.dimensionSpacePointArray(documentNode.subgraphIdentity.dimensionSpacePoint)}' - allowedPresets: '${Neos.Ui.Api.emptyArrayToObject(Neos.Ui.ContentDimensions.allowedPresetsByName(documentNode.subgraphIdentity.dimensionSpacePoint, documentNode.subgraphIdentity.contentRepositoryId))}' + allowedPresets: '${Neos.Ui.ContentDimensions.allowedPresetsByName(documentNode.subgraphIdentity.dimensionSpacePoint, documentNode.subgraphIdentity.contentRepositoryId)}' documentNodeSerialization: '${Neos.Ui.NodeInfo.renderNodeWithPropertiesAndChildrenInformation(documentNode, request)}' initialState: changes: @@ -129,7 +128,7 @@ Neos: contentDimensions: byName: '${Neos.Ui.ContentDimensions.contentDimensionsByName(contentRepositoryId)}' active: '${Neos.Ui.ContentDimensions.dimensionSpacePointArray(documentNode.subgraphIdentity.dimensionSpacePoint)}' - allowedPresets: '${Neos.Ui.Api.emptyArrayToObject(Neos.Ui.ContentDimensions.allowedPresetsByName(documentNode.subgraphIdentity.dimensionSpacePoint, contentRepositoryId))}' + allowedPresets: '${Neos.Ui.ContentDimensions.allowedPresetsByName(documentNode.subgraphIdentity.dimensionSpacePoint, contentRepositoryId)}' workspaces: personalWorkspace: '${Neos.Ui.Workspace.getPersonalWorkspace(contentRepositoryId)}' ui: From 63eb2d811db70a7724e213f6ed704096a5755277 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 6 Feb 2024 10:15:06 +0100 Subject: [PATCH 2/6] TASK: Declare `ContentDimensionsHelper` internal --- Classes/Fusion/Helper/ContentDimensionsHelper.php | 5 ++--- Classes/Fusion/Helper/NodeInfoHelper.php | 4 ++-- Configuration/Settings.yaml | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Classes/Fusion/Helper/ContentDimensionsHelper.php b/Classes/Fusion/Helper/ContentDimensionsHelper.php index ad7ab61316..745d6f1c25 100644 --- a/Classes/Fusion/Helper/ContentDimensionsHelper.php +++ b/Classes/Fusion/Helper/ContentDimensionsHelper.php @@ -11,9 +11,7 @@ * source code. */ -use Neos\ContentRepository\Core\Dimension\ContentDimension; use Neos\ContentRepository\Core\Dimension\ContentDimensionId; -use Neos\ContentRepository\Core\Dimension\ContentDimensionSourceInterface; use Neos\ContentRepository\Core\DimensionSpace\AbstractDimensionSpacePoint; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; @@ -22,7 +20,8 @@ use Neos\Flow\Annotations as Flow; /** - * @todo EEL helpers are still to be declared as internal + * @internal implementation detail of the Neos Ui to build its initialState. + * only used in EEL for the configuration Neos.Neos.Ui.initialState. */ class ContentDimensionsHelper implements ProtectedContextAwareInterface { diff --git a/Classes/Fusion/Helper/NodeInfoHelper.php b/Classes/Fusion/Helper/NodeInfoHelper.php index c04423ec1f..daaf228364 100644 --- a/Classes/Fusion/Helper/NodeInfoHelper.php +++ b/Classes/Fusion/Helper/NodeInfoHelper.php @@ -30,9 +30,9 @@ use Neos\Neos\Utility\NodeTypeWithFallbackProvider; /** - * @internal * @Flow\Scope("singleton") - * @todo EEL helpers are still to be declared as internal + * @internal implementation detail of the Neos Ui to build its initialState. + * and used for rendering node properties for the inline element wrapping from php. */ class NodeInfoHelper implements ProtectedContextAwareInterface { diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 4d145e8fbf..01ce09e450 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -99,9 +99,9 @@ Neos: content: 'Neos.Neos:Content' contentCollection: 'Neos.Neos:ContentCollection' configurationDefaultEelContext: - Neos.Ui.Workspace: Neos\Neos\Ui\Fusion\Helper\WorkspaceHelper - Neos.Ui.NodeInfo: Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper Neos.Ui.ContentDimensions: Neos\Neos\Ui\Fusion\Helper\ContentDimensionsHelper + Neos.Ui.NodeInfo: Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper + Neos.Ui.Workspace: Neos\Neos\Ui\Fusion\Helper\WorkspaceHelper Neos.Ui.StaticResources: Neos\Neos\Ui\Fusion\Helper\StaticResourcesHelper Neos.Ui.PositionalArraySorter: Neos\Neos\Ui\Fusion\Helper\PositionalArraySorterHelper documentNodeInformation: From 533ccf40792039f3df98ad16a72352b29592cb5e Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 6 Feb 2024 10:25:10 +0100 Subject: [PATCH 3/6] TASK: Declare `Neos.Ui.Workspace` internal `getAllowedTargetWorkspaces` has been removed as its unused --- Classes/Fusion/Helper/WorkspaceHelper.php | 23 +++-------------------- Configuration/Settings.yaml | 1 - 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/Classes/Fusion/Helper/WorkspaceHelper.php b/Classes/Fusion/Helper/WorkspaceHelper.php index 721c6b05aa..2c6a16f8f2 100644 --- a/Classes/Fusion/Helper/WorkspaceHelper.php +++ b/Classes/Fusion/Helper/WorkspaceHelper.php @@ -16,13 +16,12 @@ use Neos\Eel\ProtectedContextAwareInterface; use Neos\Flow\Annotations as Flow; use Neos\Flow\Security\Context; -use Neos\Neos\Domain\Service\UserService as DomainUserService; use Neos\Neos\Domain\Service\WorkspaceNameBuilder; use Neos\Neos\Ui\ContentRepository\Service\WorkspaceService; /** - * The Workspace helper for EEL contexts - * @todo EEL helpers are still to be declared as internal + * @internal implementation detail of the Neos Ui to build its initialState. + * and used for the workspace-info endpoint. */ class WorkspaceHelper implements ProtectedContextAwareInterface { @@ -38,27 +37,12 @@ class WorkspaceHelper implements ProtectedContextAwareInterface */ protected $workspaceService; - /** - * @Flow\Inject - * @var DomainUserService - */ - protected $domainUserService; - /** * @Flow\Inject * @var Context */ protected $securityContext; - /** - * @return array> - */ - public function getAllowedTargetWorkspaces(ContentRepositoryId $contentRepositoryId): array - { - $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); - return $this->workspaceService->getAllowedTargetWorkspaces($contentRepository); - } - /** * @return array */ @@ -66,6 +50,7 @@ public function getPersonalWorkspace(ContentRepositoryId $contentRepositoryId): { $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId); $currentAccount = $this->securityContext->getAccount(); + // todo use \Neos\Neos\Service\UserService::getPersonalWorkspaceName instead? $personalWorkspaceName = WorkspaceNameBuilder::fromAccountIdentifier($currentAccount->getAccountIdentifier()); $personalWorkspace = $contentRepository->getWorkspaceFinder()->findOneByName($personalWorkspaceName); @@ -83,8 +68,6 @@ public function getPersonalWorkspace(ContentRepositoryId $contentRepositoryId): } /** - * All methods are considered safe - * * @param string $methodName * @return bool */ diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 01ce09e450..014a5a60e0 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -204,6 +204,5 @@ Neos: position: 'before Neos.Neos' Fusion: defaultContext: - Neos.Ui.Workspace: Neos\Neos\Ui\Fusion\Helper\WorkspaceHelper Neos.Ui.StaticResources: Neos\Neos\Ui\Fusion\Helper\StaticResourcesHelper Neos.Ui.PositionalArraySorter: Neos\Neos\Ui\Fusion\Helper\PositionalArraySorterHelper From d7932ae21f002ef76c6ad13175866189e922b43b Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 6 Feb 2024 10:27:20 +0100 Subject: [PATCH 4/6] TASK: Declare `Neos.Ui.StaticResources` internal --- Classes/Fusion/Helper/StaticResourcesHelper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/Fusion/Helper/StaticResourcesHelper.php b/Classes/Fusion/Helper/StaticResourcesHelper.php index 6b4d1cbcfc..c7911e8f8c 100644 --- a/Classes/Fusion/Helper/StaticResourcesHelper.php +++ b/Classes/Fusion/Helper/StaticResourcesHelper.php @@ -15,7 +15,8 @@ use Neos\Flow\Annotations as Flow; /** - * @todo EEL helpers are still to be declared as internal + * @internal implementation detail of the Neos Ui to build its initialState. + * determines if to use the compiled script resources */ class StaticResourcesHelper implements ProtectedContextAwareInterface { From f22fb7858ac5cf20b4fad6f9870655ab1ffc56b6 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 6 Feb 2024 10:38:07 +0100 Subject: [PATCH 5/6] TASK: Remove `Neos.Ui.PositionalArraySorter` helper --- .../Helper/PositionalArraySorterHelper.php | 40 ------------------ Classes/Fusion/Helper/RenderingModeHelper.php | 41 +++++++++++++++++++ Configuration/Settings.yaml | 7 ++-- 3 files changed, 44 insertions(+), 44 deletions(-) delete mode 100644 Classes/Fusion/Helper/PositionalArraySorterHelper.php create mode 100644 Classes/Fusion/Helper/RenderingModeHelper.php diff --git a/Classes/Fusion/Helper/PositionalArraySorterHelper.php b/Classes/Fusion/Helper/PositionalArraySorterHelper.php deleted file mode 100644 index ee9b53fd83..0000000000 --- a/Classes/Fusion/Helper/PositionalArraySorterHelper.php +++ /dev/null @@ -1,40 +0,0 @@ - $array - * @param string $positionPath - * @return array - */ - public function sort(array $array, string $positionPath = 'position'): array - { - return (new PositionalArraySorter($array, $positionPath))->toArray(); - } - - /** - * @param string $methodName - * @return boolean - */ - public function allowsCallOfMethod($methodName) - { - return true; - } -} diff --git a/Classes/Fusion/Helper/RenderingModeHelper.php b/Classes/Fusion/Helper/RenderingModeHelper.php new file mode 100644 index 0000000000..e1b07ddd23 --- /dev/null +++ b/Classes/Fusion/Helper/RenderingModeHelper.php @@ -0,0 +1,41 @@ + + */ + protected $editPreviewModes; + + /** + * Returns the sorted configuration of all rendering modes {@see RenderingMode} + * + * todo: evaluate if this should be part of {@see RenderingModeService} + * @return array + */ + public function findAllSorted(): array + { + // sorting seems expected for the Neos.Ui: https://github.com/neos/neos-ui/issues/1658 + return (new PositionalArraySorter($this->editPreviewModes))->toArray(); + } + + public function allowsCallOfMethod($methodName) + { + return true; + } +} diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 014a5a60e0..3527f1aada 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -51,7 +51,7 @@ Neos: backgroundColor: '#ffffff' frontendConfiguration: - editPreviewModes: '${Neos.Ui.PositionalArraySorter.sort(Configuration.setting(''Neos.Neos.userInterface.editPreviewModes''))}' + editPreviewModes: '${Neos.Ui.RenderingMode.findAllSorted()}' # You may use this place to deliver some configuration to your custom UI components, e.g.: # 'Your.Own:Package': # someKey: someValue @@ -101,9 +101,9 @@ Neos: configurationDefaultEelContext: Neos.Ui.ContentDimensions: Neos\Neos\Ui\Fusion\Helper\ContentDimensionsHelper Neos.Ui.NodeInfo: Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper - Neos.Ui.Workspace: Neos\Neos\Ui\Fusion\Helper\WorkspaceHelper + Neos.Ui.RenderingMode: Neos\Neos\Ui\Fusion\Helper\RenderingModeHelper Neos.Ui.StaticResources: Neos\Neos\Ui\Fusion\Helper\StaticResourcesHelper - Neos.Ui.PositionalArraySorter: Neos\Neos\Ui\Fusion\Helper\PositionalArraySorterHelper + Neos.Ui.Workspace: Neos\Neos\Ui\Fusion\Helper\WorkspaceHelper documentNodeInformation: metaData: documentNode: '${Neos.Ui.NodeInfo.serializedNodeAddress(documentNode)}' @@ -205,4 +205,3 @@ Neos: Fusion: defaultContext: Neos.Ui.StaticResources: Neos\Neos\Ui\Fusion\Helper\StaticResourcesHelper - Neos.Ui.PositionalArraySorter: Neos\Neos\Ui\Fusion\Helper\PositionalArraySorterHelper From fa474c0beef38f2d736916c19e3a53e2f52e760f Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:03:11 +0100 Subject: [PATCH 6/6] TASK: Fix phpstan --- Classes/Fusion/Helper/RenderingModeHelper.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Classes/Fusion/Helper/RenderingModeHelper.php b/Classes/Fusion/Helper/RenderingModeHelper.php index e1b07ddd23..4c5f0da81b 100644 --- a/Classes/Fusion/Helper/RenderingModeHelper.php +++ b/Classes/Fusion/Helper/RenderingModeHelper.php @@ -25,8 +25,9 @@ final class RenderingModeHelper implements ProtectedContextAwareInterface /** * Returns the sorted configuration of all rendering modes {@see RenderingMode} * - * todo: evaluate if this should be part of {@see RenderingModeService} - * @return array + * TODO evaluate if this should be part of {@see RenderingModeService} + * + * @return array> */ public function findAllSorted(): array {