Skip to content

Commit

Permalink
Look for layout templates of all parent presenters
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar authored and Milan Felix Šulc committed Jul 28, 2018
1 parent a58c7d2 commit fa2702e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/UI/Presenter/StructuredTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,22 @@ trait StructuredTemplates
*/
public function formatLayoutTemplateFiles(): array
{
$presenterReflection = new ReflectionClass(get_called_class());
$presenterDir = dirname($presenterReflection->getFileName());
$called = get_called_class();
$classes = [$called] + class_parents($called);
$list = [];

$parentPresenterReflection = new ReflectionClass(self::class);
$parentPresenterDir = dirname($parentPresenterReflection->getFileName());
foreach ($classes as $class) {
// Skip Nette classes
if (Strings::startsWith($class, 'Nette\\')) continue;

return [
$presenterDir . '/templates/@layout.latte',
$parentPresenterDir . '/templates/@layout.latte',
];
$presenterReflection = new ReflectionClass($class);
$presenterDir = dirname($presenterReflection->getFileName());
$list[] = $presenterDir . '/templates/@layout.latte';
}

$list = array_unique($list);

return $list;
}

/**
Expand Down

0 comments on commit fa2702e

Please sign in to comment.