Skip to content

Commit

Permalink
TASK: Remove non-rendered node augmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebobo committed Jul 23, 2021
1 parent 050e58b commit c80b7cf
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 142 deletions.
99 changes: 0 additions & 99 deletions Classes/Aspects/AugmentationAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ class AugmentationAspect
*/
protected $session;

/**
* @Flow\InjectConfiguration(package="Neos.Neos.Ui", path="nodeTypeRoles")
* @var array
*/
protected $nodeTypeRoles;

/**
* Current controller context, will be set by advices
*
Expand All @@ -80,20 +74,6 @@ class AugmentationAspect
*/
protected $controllerContext = null;

/**
* All editable nodes rendered in the document
*
* @var array
*/
protected $renderedNodes = [];

/**
* String containing `<script>` tags for non rendered nodes
*
* @var string
*/
protected $nonRenderedContentNodeMetadata;

/**
* @Flow\Before("method(Neos\Neos\Fusion\ContentElementWrappingImplementation->evaluate())")
* @param JoinPointInterface $joinPoint
Expand Down Expand Up @@ -147,8 +127,6 @@ public function contentElementAugmentation(JoinPointInterface $joinPoint)
$attributes['data-__neos-node-contextpath'] = $node->getContextPath();
$attributes['data-__neos-fusion-path'] = $fusionPath;

$this->renderedNodes[] = $node->getIdentifier();

$this->userLocaleService->switchToUILocale();

$serializedNode = json_encode($this->nodeInfoHelper->renderNodeWithPropertiesAndChildrenInformation($node, $this->controllerContext));
Expand Down Expand Up @@ -204,81 +182,4 @@ protected function needsMetadata(NodeInterface $node, $renderCurrentDocumentMeta

return ($contentContext->isInBackend() === true && ($renderCurrentDocumentMetadata === true || $this->nodeAuthorizationService->isGrantedToEditNode($node) === true));
}

/**
* Concatenate strings containing `<script>` tags for all child nodes not rendered
* within the current document node. This way we can show e.g. content collections
* within the structure tree which are not actually rendered.
*
* @param NodeInterface $documentNode
* @return void
* @throws IllegalObjectTypeException
*/
protected function appendNonRenderedContentNodeMetadata(NodeInterface $documentNode)
{
if ($documentNode->getContext()->getWorkspace()->isPublicWorkspace()) {
return;
}

foreach ($documentNode->getChildNodes($this->buildFilterForNonRenderedContent()) as $node) {
if (in_array($node->getIdentifier(), $this->renderedNodes) === false) {
$serializedNode = json_encode($this->nodeInfoHelper->renderNodeWithPropertiesAndChildrenInformation($node, $this->controllerContext));
$this->nonRenderedContentNodeMetadata .= "<script>(function(){(this['@Neos.Neos.Ui:Nodes'] = this['@Neos.Neos.Ui:Nodes'] || {})['{$node->getContextPath()}'] = {$serializedNode}})()</script>";
}

if ($node->hasChildNodes() === true) {
$this->appendNonRenderedContentNodeMetadata($node);
}
}
}

/**
* Clear rendered nodes helper array to prevent possible side effects.
*/
protected function clearRenderedNodesArray()
{
$this->renderedNodes = [];
}

/**
* Clear non rendered content node metadata to prevent possible side effects.
*/
protected function clearNonRenderedContentNodeMetadata()
{
$this->nonRenderedContentNodeMetadata = '';
}

/**
* @param NodeInterface $documentNode
* @return string
* @throws IllegalObjectTypeException
*/
public function getNonRenderedContentNodeMetadata(NodeInterface $documentNode)
{
$this->userLocaleService->switchToUILocale();

$this->appendNonRenderedContentNodeMetadata($documentNode);
$nonRenderedContentNodeMetadata = $this->nonRenderedContentNodeMetadata;
$this->clearNonRenderedContentNodeMetadata();
$this->clearRenderedNodesArray();

$this->userLocaleService->switchToUILocale(true);

return $nonRenderedContentNodeMetadata;
}

/**
* @return string
*/
protected function buildFilterForNonRenderedContent()
{
$documentNodeTypes = explode(',', $this->nodeTypeRoles['document']);
$ignoredNodeTypes = explode(',', $this->nodeTypeRoles['ignored']);

$allFilteredNodeTypes = array_merge($documentNodeTypes, $ignoredNodeTypes);
$negatedNodeTypes = array_map(function ($nodeTypeName) {
return '!' . trim($nodeTypeName);
}, $allFilteredNodeTypes);
return implode(',', $negatedNodeTypes);
}
}
33 changes: 0 additions & 33 deletions Classes/Fusion/RenderNonRenderedNodeMetadataImplementation.php

This file was deleted.

10 changes: 0 additions & 10 deletions Resources/Private/Fusion/Prototypes/Page.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ prototype(Neos.Neos:Page) {
@if.inBackend = ${documentNode.context.inBackend}
}

//
// Output `<script>` tags for all non rendered node children
//
neosUiNonRenderedNodeMetadata = Neos.Neos.Ui:RenderNonRenderedNodeMetadata {
@position = 'before neosBackendNotification'
@class = 'Neos\\Neos\\Ui\\Fusion\\RenderNonRenderedNodeMetadataImplementation'
@if.inBackend = ${documentNode.context.inBackend}
node = ${node}
}

@exceptionHandler = 'Neos\\Neos\\Ui\\Fusion\\ExceptionHandler\\PageExceptionHandler'
}

Expand Down

0 comments on commit c80b7cf

Please sign in to comment.