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()
|
public function getFirstPage()
|
||||||
{
|
{
|
||||||
@ -95,25 +95,29 @@ abstract class Entry
|
|||||||
return $this->first_page;
|
return $this->first_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this instanceof Directory) {
|
if (!$this instanceof Directory) {
|
||||||
foreach ($this->value as $node) {
|
return false;
|
||||||
if ($node instanceof Content) {
|
}
|
||||||
if (!count($node->getParents()) && $node->title == 'index') {
|
|
||||||
//the homepage should not count as first page
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->first_page = $node;
|
foreach ($this->value as $node) {
|
||||||
return $node;
|
if ($node instanceof Content) {
|
||||||
}
|
if (!count($node->getParents()) && $node->title == 'index') {
|
||||||
}
|
//the homepage should not count as first page
|
||||||
foreach ($this->value as $node) {
|
continue;
|
||||||
if ($node instanceof Directory && $page = $node->getFirstPage()) {
|
|
||||||
$this->first_page = $page;
|
|
||||||
return $page;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->first_page = $node;
|
||||||
|
return $node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->value as $node) {
|
||||||
|
if ($node instanceof Directory && $page = $node->getFirstPage()) {
|
||||||
|
$this->first_page = $page;
|
||||||
|
return $page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user