From fa2702e482a2bb4e21d5b52023b5b7a53cdd72ea Mon Sep 17 00:00:00 2001 From: Marek Bartos Date: Sat, 28 Jul 2018 10:01:00 +0200 Subject: [PATCH] Look for layout templates of all parent presenters --- src/UI/Presenter/StructuredTemplates.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/UI/Presenter/StructuredTemplates.php b/src/UI/Presenter/StructuredTemplates.php index 5f463c7..5c73df1 100644 --- a/src/UI/Presenter/StructuredTemplates.php +++ b/src/UI/Presenter/StructuredTemplates.php @@ -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; } /**