protected function findItemDefinition($definitions)
{
$fallbackDefinition = null;
$types = $this->getParent()->getMixinNodeTypes();
array_push($types, $this->getParent()->getPrimaryNodeType());
/** @var $nt NodeTypeInterface */
foreach ($types as $nt) {
/** @var $candidate ItemDefinitionInterface */
foreach ($definitions($nt) as $candidate) {
if ($candidate->getName() === $this->name) {
return $candidate;
}
if ('*' === $candidate->getName()) {
// if we have multiple wildcard definitions, they are hopefully equivalent
$fallbackDefinition = $candidate;
// do not abort loop, in case we hit an exactly matching definition
}
}
}
// sanity check. theoretically, the item should not be able to
// exist if there is no definition for it
if (!$fallbackDefinition) {
throw new RepositoryException(sprintf('Found no definition for item %s, this should not be possible', $this->path));
}
return $fallbackDefinition;
}