summaryrefslogtreecommitdiff
path: root/bin/wiki/vendor/addwiki/mediawiki-api/docs/category_traverser.rst
diff options
context:
space:
mode:
Diffstat (limited to 'bin/wiki/vendor/addwiki/mediawiki-api/docs/category_traverser.rst')
-rw-r--r--bin/wiki/vendor/addwiki/mediawiki-api/docs/category_traverser.rst28
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/wiki/vendor/addwiki/mediawiki-api/docs/category_traverser.rst b/bin/wiki/vendor/addwiki/mediawiki-api/docs/category_traverser.rst
new file mode 100644
index 00000000..497398e8
--- /dev/null
+++ b/bin/wiki/vendor/addwiki/mediawiki-api/docs/category_traverser.rst
@@ -0,0 +1,28 @@
+Category Traversal
+==================
+
+The CategoryTraverser class is used to start at one Category page in a wiki's category hierarchy
+and descend through that category's children, grandchildren, and so on.
+The basic output of this is a Pages object containing all the pages in the category tree.
+It is also possible to register callbacks that will be called
+for every subcategory or other page (i.e. anything not a category).
+
+Basic usage
+-----------
+
+To get all pages in a category or any of its subcategories.
+
+.. code-block:: php
+ :linenos:
+
+ // Construct the API.
+ $api = new \Mediawiki\Api\MediawikiApi( 'http://localhost/w/api.php' );
+ $services = new \Mediawiki\Api\MediawikiFactory( $api );
+ $categoryTraverser = $services->newCategoryTraverser();
+
+ // Get the root category.
+ $rootCatIdent = new PageIdentifier( new Title( 'Category:Categories' ) );
+ $rootCat = $this->factory->newPageGetter()->getFromPageIdentifier( $pageIdentifier );
+
+ // Get all pages.
+ $allPages = $categoryTraverser->descend( $rootCat );