Skip to content

Commit

Permalink
check rendering mode and hide hidden nodes to fix flownative#41
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruggmann committed Mar 27, 2024
1 parent 4bd4cd5 commit 91b3a9c
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions Classes/Aspects/NodeConverterAspect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
namespace Flownative\WorkspacePreview\Aspects;

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Aop\JoinPointInterface;
use Neos\Flow\Security\Context;
use Neos\Neos\Domain\Service\UserInterfaceModeService;

/**
* @Flow\Scope("singleton")
* @Flow\Aspect
*/
class NodeConverterAspect
{

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

/**
* @Flow\Inject
* @var UserInterfaceModeService
*/
protected $userInterfaceModeService;

/**
* @Flow\Around("method(Neos\ContentRepository\TypeConverter\NodeConverter->prepareContextProperties())")
* @param \Neos\Flow\Aop\JoinPointInterface $joinPoint The current join point
* @return array
*/
public function suppressInvisibleContentShown(JoinPointInterface $joinPoint)
{
$contextProperties = $joinPoint->getAdviceChain()->proceed($joinPoint);
$workspaceName = $joinPoint->getMethodArgument('workspaceName');

try {
if (
$workspaceName !== 'live'
&& (
$this->userInterfaceModeService->findModeByCurrentUser()->isPreview()
|| $this->securityContext->hasRole('Flownative.WorkspacePreview:WorkspacePreviewer')
)
) {
$contextProperties['invisibleContentShown'] = false;
}
} catch (\Neos\Flow\Security\Exception\NoSuchRoleException|\Neos\Flow\Security\Exception $e) {
// ignore
}

return $contextProperties;
}
}

0 comments on commit 91b3a9c

Please sign in to comment.