Skip to content
This repository has been archived by the owner on Dec 27, 2018. It is now read-only.

Commit

Permalink
Cleaning code of Layout class.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny committed Aug 30, 2016
1 parent 491d90f commit 3569b89
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/Renderer/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,20 @@ public function finder(Page $page, Config $config)
$layouts = self::fallback($page);

// is layout exists in local layout dir?
$layoutsDir = $config->getLayoutsPath();
foreach ($layouts as $layout) {
if (Util::getFS()->exists($layoutsDir.'/'.$layout)) {
if (Util::getFS()->exists($config->getLayoutsPath().'/'.$layout)) {
return $layout;
}
}
// is layout exists in layout theme dir?
if ($config->hasTheme()) {
$themeDir = $config->getThemePath($config->get('theme'));
foreach ($layouts as $layout) {
if (Util::getFS()->exists($themeDir.'/'.$layout)) {
if (Util::getFS()->exists($config->getThemePath($config->get('theme')).'/'.$layout)) {
return $layout;
}
}
}

throw new Exception(sprintf("Layout '%s' not found for page '%s'!", $layout, $page->getId()));
}

Expand Down Expand Up @@ -136,17 +135,16 @@ protected static function fallback(Page $page)
$layouts
);
}
} else {
}
$layouts = array_merge(
['page.html.twig'],
$layouts
);
if ($page->getLayout()) {
$layouts = array_merge(
['page.html.twig'],
[sprintf('%s.twig', $layout)],
$layouts
);
if ($page->getLayout()) {
$layouts = array_merge(
[sprintf('%s.twig', $layout)],
$layouts
);
}
}
}

Expand Down

0 comments on commit 3569b89

Please sign in to comment.