daux.io/libs/Tree/Root.php

62 lignes
1.2 KiB
PHP
Brut Vue normale Historique

<?php namespace Todaymade\Daux\Tree;
use Todaymade\Daux\Config;
class Root extends Directory
{
/** @var Config */
protected $config;
/** @var Entry */
protected $activeNode;
/**
2020-04-22 22:24:52 +02:00
* The root doesn't have a parent.
*/
public function __construct(Config $config)
{
$this->setConfig($config);
$this->setUri($config->getDocumentationDirectory());
$this->path = $config->getDocumentationDirectory();
}
public function getConfig(): Config
{
return $this->config;
}
public function setConfig(Config $config)
{
$this->config = $config;
}
2020-04-22 21:55:53 +02:00
public function isHotPath(Entry $node = null): bool
{
if ($node == null) {
return true;
}
if ($this->activeNode == null) {
return false;
}
if ($node == $this->activeNode) {
return true;
}
foreach ($this->activeNode->getParents() as $parent) {
2019-12-29 22:40:34 +01:00
if ($node === $parent) {
return true;
}
}
return false;
}
2020-04-22 21:55:53 +02:00
public function setActiveNode(Entry $node)
{
$this->activeNode = $node;
}
}