Refactor getFirstPage
This commit is contained in:
parent
ce109d0429
commit
71d1041cb8
@ -87,7 +87,7 @@ abstract class Entry
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Content
|
||||
* @return Content|false
|
||||
*/
|
||||
public function getFirstPage()
|
||||
{
|
||||
@ -95,7 +95,10 @@ abstract class Entry
|
||||
return $this->first_page;
|
||||
}
|
||||
|
||||
if ($this instanceof Directory) {
|
||||
if (!$this instanceof Directory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($this->value as $node) {
|
||||
if ($node instanceof Content) {
|
||||
if (!count($node->getParents()) && $node->title == 'index') {
|
||||
@ -107,13 +110,14 @@ abstract class Entry
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->value as $node) {
|
||||
if ($node instanceof Directory && $page = $node->getFirstPage()) {
|
||||
$this->first_page = $page;
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user