Skip to content
Draft
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
14 changes: 2 additions & 12 deletions Neos.Neos/Classes/Fusion/ContentElementWrappingImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ public function getValue(): string
return (string)$this->fusionValue('value');
}

/**
* Additional attributes to be rendered in the ContentElementWrapping
*
* @return array<string,string>
*/
public function getAdditionalAttributes(): array
{
return $this->fusionValue('additionalAttributes') ?? [];
}

/**
* Evaluate this Fusion object and return the result
*
Expand All @@ -78,15 +68,15 @@ public function evaluate()
return $content;
}

// TODO: Move this check to the service and only check once for the privilege for the current request
if (!$this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess')) {
return $content;
}

return $this->contentElementWrappingService->wrapContentObject(
$node,
$content,
$this->getContentElementFusionPath(),
$this->getAdditionalAttributes()
$this->getContentElementFusionPath()
);
}

Expand Down
4 changes: 0 additions & 4 deletions Neos.Neos/Classes/Service/ContentElementEditableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ class ContentElementEditableService

public function wrapContentProperty(Node $node, string $property, string $content): string
{
$contentRepository = $this->contentRepositoryRegistry->get(
$node->contentRepositoryId
);

// TODO: permissions
//if (!$this->nodeAuthorizationService->isGrantedToEditNode($node)) {
// return $content;
Expand Down
35 changes: 5 additions & 30 deletions Neos.Neos/Classes/Service/ContentElementWrappingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Fusion\Service\HtmlAugmenter as FusionHtmlAugmenter;

/**
* The content element wrapping service adds the necessary markup around
Expand All @@ -29,11 +28,6 @@
*/
class ContentElementWrappingService
{
/**
* @Flow\Inject
* @var FusionHtmlAugmenter
*/
protected $htmlAugmenter;

/**
* @Flow\Inject
Expand All @@ -43,38 +37,19 @@ class ContentElementWrappingService

/**
* Wrap the $content identified by $node with the needed markup for the backend.
*
* @param array<string,string> $additionalAttributes
*/
public function wrapContentObject(
Node $node,
string $content,
string $fusionPath,
array $additionalAttributes = []
string $fusionPath
): ?string {
$contentRepository = $this->contentRepositoryRegistry->get(
$node->contentRepositoryId
);

// TODO: reenable permissions
//if ($this->nodeAuthorizationService->isGrantedToEditNode($node) === false) {
// return $content;
//}


$nodeAddress = NodeAddress::fromNode($node);
$attributes = $additionalAttributes;
$attributes['data-__neos-fusion-path'] = $fusionPath;
$attributes['data-__neos-node-contextpath'] = $nodeAddress->toJson();

// Define all attribute names as exclusive via the `exclusiveAttributes` parameter, to prevent the data of
// two different nodes to be concatenated into the attributes of a single html node.
// This way an outer div is added, if the wrapped content already has node related data-attributes set.
return $this->htmlAugmenter->addAttributes(
$content,
$attributes,
'div',
array_keys($attributes)
);
$nodeAddressJson = NodeAddress::fromNode($node)->toJson();
$htmlCommentStart = '<!--__NEOS_UI_NODE_START__ ' . $nodeAddressJson . '__' . $fusionPath . '-->';
$htmlCommentEnd = '<!--__NEOS_UI_NODE_END__' . $nodeAddressJson . '-->';
return $htmlCommentStart . $content . $htmlCommentEnd;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ prototype(Neos.Neos:ContentElementWrapping) {
@if.inEditMode = ${renderingMode.isEdit}
node = ${node}
value = ${value}
# Additional attributes in the form '<attribute-name>': '<attribute-value>' that will be rendered in the ContentElementWrapping
additionalAttributes = Neos.Fusion:DataStructure
}
Loading