Refactor getFirstPage

Cette révision appartient à :
Stéphane Goetz 2015-07-18 01:14:44 +02:00
Parent ce109d0429
révision 71d1041cb8
1 fichiers modifiés avec 20 ajouts et 16 suppressions

Voir le fichier

@ -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;
}