This repository has been archived on 2024-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
dokuwiki-objectrepresentation/lib/enko/dokuwiki/objectrepresentation/DokuWikiIterator.php
Tim Schumacher 0b248d7dec Add a option to load the changesets.
The default is, not to load the changesets.
2014-06-14 09:29:13 +02:00

78 lines
No EOL
1.6 KiB
PHP
Executable file

<?php
/**
* Created by PhpStorm.
* User: tim
* Date: 12.06.14
* Time: 21:56
*/
namespace enko\dokuwiki\objectrepresentation;
class DokuWikiIterator
{
/**
* @var DokuWikiNameSpace
*/
private $root;
/**
* @param callable $callback
*/
public function runMetadataExtractor(Callable $callback)
{
$this->all($callback);
}
/**
* @param DokuWikiNameSpace $ns
* @param callable $callback
*/
private function _all(DokuWikiNameSpace $ns, Callable $callback)
{
$callback($ns);
foreach ($ns->nodes as $node) {
/** $node DokuWikiNode */
if ($node instanceof DokuWikiPage) {
$callback($node);
}
if ($node instanceof DokuWikiNameSpace) {
$this->_all($node, $callback);
}
}
}
/**
* @param callable $callback
* @return $this
*/
public function all(Callable $callback)
{
$this->_all($this->root, $callback);
return $this;
}
/**
*
*/
public function __construct($loadChangesets = false, \DateTime $maxChangeSetAge = null)
{
global $conf;
$basedir = $conf['datadir'];
$this->root = new DokuWikiNameSpace($basedir, null, $loadChangesets, $maxChangeSetAge);
}
/**
* @return string
*/
public function toString()
{
return $this->root->toString();
}
public function getRoot()
{
return $this->root;
}
}