/**
* Checks if the given $nodeType is allowed as a childNode of the given $childNodeName
* (which must be auto-created in $this NodeType).
*
* Only allowed to be called if $childNodeName is auto-created.
*
* @param string $childNodeName The name of a configured childNode of this NodeType
* @param NodeType $nodeType The NodeType to check constraints for.
* @return boolean TRUE if the $nodeType is allowed as grandchild node, FALSE otherwise.
* @throws \InvalidArgumentException If the given $childNodeName is not configured to be auto-created in $this.
*/
public function allowsGrandchildNodeType($childNodeName, NodeType $nodeType)
{
$autoCreatedChildNodes = $this->getAutoCreatedChildNodes();
if (!isset($autoCreatedChildNodes[$childNodeName])) {
throw new \InvalidArgumentException('The method "allowsGrandchildNodeType" can only be used on auto-created childNodes, given $childNodeName "' . $childNodeName . '" is not auto-created.', 1403858395);
}
$constraints = $autoCreatedChildNodes[$childNodeName]->getConfiguration('constraints.nodeTypes') ?: array();
$childNodeConfiguration = [];
foreach ($this->getConfiguration('childNodes') as $name => $configuration) {
$childNodeConfiguration[Utility::renderValidNodeName($name)] = $configuration;
}
$childNodeConstraintConfiguration = ObjectAccess::getPropertyPath($childNodeConfiguration, $childNodeName . '.constraints.nodeTypes') ?: array();
$constraints = Arrays::arrayMergeRecursiveOverrule($constraints, $childNodeConstraintConfiguration);
return $this->isNodeTypeAllowedByConstraints($nodeType, $constraints);
}