1
0
Fork 0
mirror of https://github.com/Oreolek/yii2-nested-sets.git synced 2024-06-29 04:55:00 +03:00
Go to file
2015-01-01 13:06:25 +03:00
tests Base for unit tests added 2015-01-01 09:10:10 +03:00
.gitignore .gitignore updated 2014-01-17 10:47:08 +04:00
.travis.yml Added Travis CI configuration file 2015-01-01 13:06:25 +03:00
composer.json Nested sets behavior complete overhaul for Yii 2 framework release version 2015-01-01 09:08:05 +03:00
LICENSE.md Nested sets behavior complete overhaul for Yii 2 framework release version 2015-01-01 09:08:05 +03:00
NestedSetsBehavior.php Nested sets behavior complete overhaul for Yii 2 framework release version 2015-01-01 09:08:05 +03:00
NestedSetsQueryBehavior.php Nested sets behavior complete overhaul for Yii 2 framework release version 2015-01-01 09:08:05 +03:00
phpunit.xml.dist Base for unit tests added 2015-01-01 09:10:10 +03:00
README.md README.md updated 2015-01-01 11:04:23 +03:00

Nested Sets Behavior for Yii 2

PayPal - The safer, easier way to pay online!

Introduction

The nested sets behavior for the Yii framework.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require creocoder/yii2-nested-sets "dev-master"

or add

"creocoder/yii2-nested-sets": "dev-master"

to the require section of your composer.json file.

Configuring

First you need to configure model as follows:

use creocoder\nestedsets\NestedSetsBehavior;

class Tree extends \yii\db\ActiveRecord
{
    public function behaviors() {
        return [
            NestedSetsBehavior::className(),
        ];
    }

    public function transactions()
    {
        return [
            self::SCENARIO_DEFAULT => self::OP_ALL,
        ];
    }

    public static function find()
    {
        return new TreeQuery(get_called_class());
    }
}

Second you need to configure query model as follows:

use creocoder\nestedsets\NestedSetsQueryBehavior;

class TreeQuery extends \yii\db\ActiveQuery
{
    public function behaviors() {
        return [
            NestedSetsQueryBehavior::className(),
        ];
    }
}

Usage

TBD.