previousnext/nested-set
最新稳定版本:2.0.1
Composer 安装命令:
composer require previousnext/nested-set
包简介
A PHP Doctrine DBAL implementation for Nested Sets.
README 文档
README
A PHP Doctrine DBAL implementation for Nested Sets.
Using
Create table schema
Create the table schema, passing in a a DBAL connection and table name (defaults to 'tree').
$schema = new DbalNestedSetSchema($connection, 'my_tree'); schema->create();
Set up the nested set client
Create a new DbalNestedSet passing in the DBAL connection and the table name.
$nestedSet = new DbalNestedSet($connection, 'my_tree');
Add a root node
A NodeKey represents a unique ID for a node in the tree. It supports the idea of a node ID and a revision ID, mostly for compatibility with Drupal.
$nodeKey = new NodeKey($id, $revisionId); $rootNode = $nestedSet->addRootNode($nodeKey);
Add a child node
To add a child node, you provide the parent node, and a child node key.
$nodeKey = new NodeKey($id, $revisionId); $nestedSet->addNodeBelow($rootNode, $nodeKey);
Find Descendants
To find descendents, you provide the parent node key.
$nodeKey = new NodeKey($id, $revisionId); $descendants = $this->nestedSet->findDescendants($nodeKey);
Find ancestors
To find ancestors, you provide the child node key.
$nodeKey = new NodeKey($id, $revisionId); $ancestors = $this->nestedSet->findAncestors($nodeKey);
See \PNX\NestedSet\NestedSetInterface for many more methods that can be used for interacting with the nested set.
Developing
Dependencies
To install all dependencies, run:
make init
Linting
Uses the Drupal coding standard.
To validate code sniffs run:
make lint-php
To automatically fix code sniff issues, run:
make fix-php
Testing
To run all phpunit tests, run:
make test
统计信息
- 总下载量: 1.07M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2016-11-30