forked from flownative/neos-workspace-preview
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check rendering mode and hide hidden nodes to fix flownative#41
- Loading branch information
1 parent
4bd4cd5
commit 91b3a9c
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |