lib/doc: Rename Section to DocSection and let it extend TreeNode

refs #6630
This commit is contained in:
Eric Lippmann 2015-02-06 17:29:04 +01:00
parent 0d63e14baf
commit ecfda1a6f5
1 changed files with 36 additions and 49 deletions

View File

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