Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Cleanup, remove or declare EEL helpers as internal #3711

Merged
merged 6 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 0 additions & 43 deletions Classes/Fusion/Helper/ApiHelper.php

This file was deleted.

13 changes: 6 additions & 7 deletions Classes/Fusion/Helper/ContentDimensionsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -69,10 +68,9 @@ public function contentDimensionsByName(ContentRepositoryId $contentRepositoryId

/**
* @param DimensionSpacePoint $dimensions Dimension values indexed by dimension name
* @return array<string,array<int,string>> Allowed preset names for the given dimension combination
* indexed by dimension name
* @return array<string,array<int,string>>|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;
Expand All @@ -89,7 +87,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<string,array<int,string>> */
Expand Down
4 changes: 2 additions & 2 deletions Classes/Fusion/Helper/NodeInfoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
40 changes: 0 additions & 40 deletions Classes/Fusion/Helper/PositionalArraySorterHelper.php

This file was deleted.

42 changes: 42 additions & 0 deletions Classes/Fusion/Helper/RenderingModeHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace Neos\Neos\Ui\Fusion\Helper;

use Neos\Eel\ProtectedContextAwareInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Model\RenderingMode;
use Neos\Neos\Domain\Service\RenderingModeService;
use Neos\Utility\PositionalArraySorter;

/**
* @internal implementation detail of the Neos Ui to build its initialState.
* only used in EEL for the configuration Neos.Neos.Ui.initialState.
*/
final class RenderingModeHelper implements ProtectedContextAwareInterface
{
/**
* @Flow\InjectConfiguration(path="userInterface.editPreviewModes", package="Neos.Neos")
* @var array<string,mixed>
*/
protected $editPreviewModes;

/**
* Returns the sorted configuration of all rendering modes {@see RenderingMode}
*
* TODO evaluate if this should be part of {@see RenderingModeService}
*
* @return array<string,array<mixed>>
*/
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;
}
}
3 changes: 2 additions & 1 deletion Classes/Fusion/Helper/StaticResourcesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
23 changes: 3 additions & 20 deletions Classes/Fusion/Helper/WorkspaceHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -38,34 +37,20 @@ class WorkspaceHelper implements ProtectedContextAwareInterface
*/
protected $workspaceService;

/**
* @Flow\Inject
* @var DomainUserService
*/
protected $domainUserService;

/**
* @Flow\Inject
* @var Context
*/
protected $securityContext;

/**
* @return array<string,array<string,mixed>>
*/
public function getAllowedTargetWorkspaces(ContentRepositoryId $contentRepositoryId): array
{
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
return $this->workspaceService->getAllowedTargetWorkspaces($contentRepository);
}

/**
* @return array<string,mixed>
*/
public function getPersonalWorkspace(ContentRepositoryId $contentRepositoryId): array
{
$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);

Expand All @@ -83,8 +68,6 @@ public function getPersonalWorkspace(ContentRepositoryId $contentRepositoryId):
}

/**
* All methods are considered safe
*
* @param string $methodName
* @return bool
*/
Expand Down
15 changes: 6 additions & 9 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -99,20 +99,19 @@ 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
Neos.Ui.NodeInfo: Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper
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)}'
siteNode: '${Neos.Ui.NodeInfo.serializedNodeAddress(site)}'
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:
Expand All @@ -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:
Expand Down Expand Up @@ -205,6 +204,4 @@ 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
Loading