Neos\ContentRepository\Domain\Model\NodeType::isNodeTypeAllowedByInheritanceConstraints PHP Method

isNodeTypeAllowedByInheritanceConstraints() protected method

This method loops over the constraints and finds node types that the given node type inherits from. For all matched super types, their super types are traversed to find the closest super node with a constraint which is used to evaluated if the node type is allowed. It finds the closest results for true and false, and uses the distance to choose which one wins (lowest). If no result is found the node type is allowed.
protected isNodeTypeAllowedByInheritanceConstraints ( NodeType $nodeType, array $constraints ) : boolean | null
$nodeType NodeType
$constraints array
return boolean | null if no constraint matched
    protected function isNodeTypeAllowedByInheritanceConstraints(NodeType $nodeType, array $constraints)
    {
        $constraintDistanceForTrue = null;
        $constraintDistanceForFalse = null;
        foreach ($constraints as $superType => $constraint) {
            if ($nodeType->isOfType($superType)) {
                $distance = $this->traverseSuperTypes($nodeType, $superType, 0);
                if ($constraint === true && ($constraintDistanceForTrue === null || $constraintDistanceForTrue > $distance)) {
                    $constraintDistanceForTrue = $distance;
                }
                if ($constraint === false && ($constraintDistanceForFalse === null || $constraintDistanceForFalse > $distance)) {
                    $constraintDistanceForFalse = $distance;
                }
            }
        }
        if ($constraintDistanceForTrue !== null && $constraintDistanceForFalse !== null) {
            return $constraintDistanceForTrue < $constraintDistanceForFalse ? true : false;
        }
        if ($constraintDistanceForFalse !== null) {
            return false;
        }
        if ($constraintDistanceForTrue !== null) {
            return true;
        }
        return null;
    }