Skip to content

Commit 8b31feb

Browse files
committed
OXDEV-9553 Fix getting the last child in a template chain
1 parent 8c6498f commit 8b31feb

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/Resolver/TemplateChain/DataObject/TemplateChain.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,20 @@ public function getParent(TemplateTypeInterface $templateType): TemplateTypeInte
7676

7777
public function getLastChild(): TemplateTypeInterface
7878
{
79-
reset($this->chain);
80-
return current($this->chain);
79+
$extendedNamespaces = [];
80+
$lastChild = null;
81+
82+
foreach ($this->chain as $templateType) {
83+
$parentNamespace = $templateType->getParentNamespace();
84+
if ($parentNamespace) {
85+
$extendedNamespaces[$parentNamespace] = true;
86+
}
87+
if (!isset($extendedNamespaces[$templateType->getNamespace()])) {
88+
$lastChild = $templateType;
89+
}
90+
}
91+
92+
return $lastChild ?? reset($this->chain);
8193
}
8294

8395
public function hasParent(TemplateTypeInterface $templateType): bool

0 commit comments

Comments
 (0)