Skip to content

Commit

Permalink
Improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
martialblog committed Aug 2, 2024
1 parent c7a350b commit 936184c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
39 changes: 39 additions & 0 deletions doc/80-Development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Development

A short overview of the TLV classes and their roles.

`ViewConfig` is responsable for managing the YAML files that contain
the views.

```
$c = new ViewConfig($modules_config_dir)
$views = $c->loadAll();
$view = $c->loadByName('myview');
```

This class also handles storing/loading the view data into either YAML files
or the user's session.

`Model\View` represents a single Top Level View and is
responsable for parsing the YAML data.

It also contains the tree data structure representing the view's hierarchy.
The `getTree()` method will return this tree.

`Tree\TLVTree` represents the root of the TLV tree.
It store and load itself from the Icinga Web `FileCache` via the `storeCache()/loadCache()` methods.

`Tree\TLVTreeNode` represents a node in the TLV tree.

Each node has an numeric ID based on its position in the tree (example: 9, 9-0, 9-1, 9-0-1).
This ID is also used in HTML links to show a subtree.

This class is used in recursively rendering the tree into HTML.

`Tree\TLVIcingaNode` is a tree node that can fetch Icinga data from the database.

Each of the classes `Tree\TLVHostGroupNode`, `Tree\TLVHostNode`, `Tree\TLVServiceNode` extends this class.

Each node uses the `fetch()` method to retrieve its data from the database

They use `Tree\TLVStatus` to represent their current status, which is determined with `getStatus()` method of each node.
9 changes: 9 additions & 0 deletions library/Toplevelview/Model/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ protected function ensureParsed()
}
}

/**
* getMeta returns a value from the View's metadata.
* Metadata are root elemts in the YAML file that are not 'children'
* @throws ProgrammingError if you try to edit children here
*/
public function getMeta($key)
{
$this->ensureParsed();
Expand All @@ -141,6 +146,10 @@ public function setMeta($key, $value)
return $this;
}

/**
* getMetaData returns all YAML root elements that are not 'childen',
* thus the View's metadata.
*/
public function getMetaData()
{
$this->ensureParsed();
Expand Down

0 comments on commit 936184c

Please sign in to comment.