From ecfda1a6f5077b4b0494fc3af90bdfd894faf8bf Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 6 Feb 2015 17:29:04 +0100 Subject: [PATCH] lib/doc: Rename Section to DocSection and let it extend TreeNode refs #6630 --- .../Doc/{Section.php => DocSection.php} | 85 ++++++++----------- 1 file changed, 36 insertions(+), 49 deletions(-) rename modules/doc/library/Doc/{Section.php => DocSection.php} (50%) diff --git a/modules/doc/library/Doc/Section.php b/modules/doc/library/Doc/DocSection.php similarity index 50% rename from modules/doc/library/Doc/Section.php rename to modules/doc/library/Doc/DocSection.php index 32f836c33..237b487fc 100644 --- a/modules/doc/library/Doc/Section.php +++ b/modules/doc/library/Doc/DocSection.php @@ -3,81 +3,52 @@ namespace Icinga\Module\Doc; -use Icinga\Data\Identifiable; +use Icinga\Data\Tree\TreeNode; /** * A section of a documentation */ -class Section implements Identifiable +class DocSection extends TreeNode { - /** - * The ID of the section - * - * @var string - */ - protected $id; - /** * The title of the section * - * @var string + * @type string */ protected $title; /** * The header level * - * @var int + * @type int */ protected $level; /** * Whether to instruct search engines to not index the link to the section * - * @var bool + * @type bool */ protected $noFollow; - /** - * The ID of the chapter the section is part of - * - * @var string - */ - protected $chapterId; - /** * The content of the section * - * @var array + * @type array */ protected $content = array(); /** - * Create a new section + * Set the title of the section * - * @param string $id The ID of the section - * @param string $title The title of the section - * @param int $level The header level - * @param bool $noFollow Whether to instruct search engines to not index the link to the section - * @param string $chapterId The ID of the chapter the section is part of - */ - public function __construct($id, $title, $level, $noFollow, $chapterId) - { - $this->id = $id; - $this->title = $title; - $this->level = $level; - $this->noFollow = $noFollow; - $this->chapterId= $chapterId; - } - - /** - * Get the ID of the section + * @param string $title Title of the section * - * @return string + * @return $this */ - public function getId() + public function setTitle($title) { - return $this->id; + $this->title = (string) $title; + return $this; } /** @@ -90,6 +61,19 @@ class Section implements Identifiable return $this->title; } + /** + * Set the header level + * + * @param int $level Header level + * + * @return $this + */ + public function setLevel($level) + { + $this->level = (int) $level; + return $this; + } + /** * Get the header level * @@ -101,23 +85,26 @@ class Section implements Identifiable } /** - * Whether to instruct search engines to not index the link to the section + * Set whether to instruct search engines to not index the link to the section * - * @return bool + * @param bool $noFollow Whether to instruct search engines to not index the link to the section + * + * @return $this */ - public function isNoFollow() + public function setNoFollow($noFollow = true) { - return $this->noFollow; + $this->noFollow = (bool) $noFollow; + return $this; } /** - * The ID of the chapter the section is part of + * Get whether to instruct search engines to not index the link to the section * - * @return string + * @return bool */ - public function getChapterId() + public function getNoFollow() { - return $this->chapterId; + return $this->noFollow; } /**