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

traverseSuperTypes() protected method

In case the hierarchy has more than one way of finding a path to the node type it's not taken into account, since the first matched is returned. This is accepted on purpose for performance reasons and due to the fact that such hierarchies should be avoided.
protected traverseSuperTypes ( NodeType $currentNodeType, string $constraintNodeTypeName, integer $distance ) : integer
$currentNodeType NodeType
$constraintNodeTypeName string
$distance integer
return integer or NULL if no NodeType matched
    protected function traverseSuperTypes(NodeType $currentNodeType, $constraintNodeTypeName, $distance)
    {
        if ($currentNodeType->getName() === $constraintNodeTypeName) {
            return $distance;
        }
        $distance++;
        foreach ($currentNodeType->getDeclaredSuperTypes() as $superType) {
            $result = $this->traverseSuperTypes($superType, $constraintNodeTypeName, $distance);
            if ($result !== null) {
                return $result;
            }
        }
        return null;
    }