2015-07-18 20:52:14 +02:00
|
|
|
<?php namespace Todaymade\Daux\Tree;
|
|
|
|
|
2015-07-18 23:13:02 +02:00
|
|
|
use Todaymade\Daux\Config;
|
|
|
|
|
2015-07-18 20:52:14 +02:00
|
|
|
class Root extends Directory
|
|
|
|
{
|
2015-07-18 23:13:02 +02:00
|
|
|
/** @var Config */
|
|
|
|
protected $config;
|
|
|
|
|
2017-01-09 18:29:52 +01:00
|
|
|
/** @var Entry */
|
|
|
|
protected $activeNode;
|
|
|
|
|
2015-07-18 20:52:14 +02:00
|
|
|
/**
|
|
|
|
* The root doesn't have a parent
|
|
|
|
*/
|
2016-07-27 23:27:51 +02:00
|
|
|
public function __construct(Config $config)
|
2015-07-18 20:52:14 +02:00
|
|
|
{
|
2015-07-18 23:13:02 +02:00
|
|
|
$this->setConfig($config);
|
|
|
|
|
2016-07-27 23:27:51 +02:00
|
|
|
$this->setUri($config->getDocumentationDirectory());
|
|
|
|
$this->path = $config->getDocumentationDirectory();
|
2015-07-18 20:52:14 +02:00
|
|
|
}
|
2015-07-18 23:13:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Config
|
|
|
|
*/
|
|
|
|
public function getConfig()
|
|
|
|
{
|
|
|
|
return $this->config;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Config $config
|
|
|
|
*/
|
|
|
|
public function setConfig($config)
|
|
|
|
{
|
|
|
|
$this->config = $config;
|
|
|
|
}
|
2017-01-09 18:29:52 +01:00
|
|
|
|
|
|
|
public function isHotPath(Entry $node = null) {
|
|
|
|
if ($node == null) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->activeNode == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($node == $this->activeNode) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($this->activeNode->getParents() as $parent) {
|
|
|
|
if ($node == $parent) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setActiveNode(Entry $node) {
|
|
|
|
$this->activeNode = $node;
|
|
|
|
}
|
2015-07-18 20:52:14 +02:00
|
|
|
}
|