/**
* Returns the node types that the currently authenticated user is *denied* to create within the given $referenceNode
*
* @param NodeInterface $referenceNode
* @return string[] Array of granted node type names
*/
public function getNodeTypeNamesDeniedForCreation(NodeInterface $referenceNode)
{
$privilegeSubject = new CreateNodePrivilegeSubject($referenceNode);
$allNodeTypes = $this->nodeTypeManager->getNodeTypes();
$deniedCreationNodeTypes = array();
$grantedCreationNodeTypes = array();
$abstainedCreationNodeTypes = array();
foreach ($this->securityContext->getRoles() as $role) {
/** @var CreateNodePrivilege $createNodePrivilege */
foreach ($role->getPrivilegesByType(CreateNodePrivilege::class) as $createNodePrivilege) {
if (!$createNodePrivilege->matchesSubject($privilegeSubject)) {
continue;
}
$affectedNodeTypes = $createNodePrivilege->getCreationNodeTypes() !== array() ? $createNodePrivilege->getCreationNodeTypes() : $allNodeTypes;
if ($createNodePrivilege->isGranted()) {
$grantedCreationNodeTypes = array_merge($grantedCreationNodeTypes, $affectedNodeTypes);
} elseif ($createNodePrivilege->isDenied()) {
$deniedCreationNodeTypes = array_merge($deniedCreationNodeTypes, $affectedNodeTypes);
} else {
$abstainedCreationNodeTypes = array_merge($abstainedCreationNodeTypes, $affectedNodeTypes);
}
}
}
$implicitlyDeniedNodeTypes = array_diff($abstainedCreationNodeTypes, $grantedCreationNodeTypes);
return array_merge($implicitlyDeniedNodeTypes, $deniedCreationNodeTypes);
}