Download the PHP package kl83/yii2-sortable-behaviour without Composer

On this page you can find all versions of the php package kl83/yii2-sortable-behaviour. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-sortable-behaviour

Yii2 sortable behaviour

Latest Stable Version Total Downloads License

Provides functionality for sorting and moving model instances in a hierarchical structure of adjacency table.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require kl83/yii2-sortable-behaviour ~1.1.0

or add

"kl83/yii2-sortable-behaviour": "~1.1.0"

to the require section of your composer.json file.

Usage

Add behaviour to your model.

public function behaviors()
{
    return [
        [
            'class' => 'kl83\behaviours\SortableBehaviour',
            'sortField' => 'sort',
            'parentIdField' => 'parent_id',
        ],
    ];
}

Behaviour configuration

Option Default Description
sortField idx Table field containing the order of model instances.
parentIdField parentId Table field containing the identifier of the parent model instance.
titleField null Table field containing the name of the model instance. If not set, tries to use "name" or "title".
defaultSortVal 4294967295 The value of the sort field for the new model instance. By default, a new instance of the model will be the last.
cache null The cache object to use. By default, Yii::$app->cache is used, if it is set. If not, then DummyCache is used.

Behaviour functions

Moves the model instance to the beginning of $parentId domain. If $parentId is not set, then the model instance will be the first in its current domain.


Moves the model instance to the end of $parentId domain. If $parentId is not set, then the model instance will be the last in its current domain.


Moves the model instance after $model. If $model is empty, then moves the model instance to the beginning of his domain.


Moves the model instance before $model.


Returns an array of instance IDs of child models. If $all is true, it also includes all sublevels.


Returns ActiveQuery to get child models.


Returns ActiveQuery to get instances of child models, including all sublevels.


Returns an instance of the parent model.


Returns an array of instance IDs of parent models. Ordered by depth level.


Returns ActiveQuery to get instances of parent models.


Returns an instance of the root model.


Returns the full path of the model instance. $callable is function to stringify model for output as path element. Simple $callable example:


Returns an instance of the joint parent of the current model and $model.


Sorting model instances in alphabetical order.


Returns the identifiers of the child model instances, including all sublevels. Also include instance IDs of the parent models, if $includeParents is true.


Returns ActiveQuery to get child model instances, including all sublevels. And instances of the parent models, if $includeParents is true.

PHPDoc model class heading

 * @method null moveFirst(integer $parentId = false)
 * Moves the model instance to the beginning of $parentId domain.
 * If $parentId is not set, then the model instance will be the first in its current domain.
 *
 * @method null moveLast(integer $parentId = false)
 * Moves the model instance to the end of $parentId domain.
 * If $parentId is not set, then the model instance will be the last in its current domain.
 *
 * @method null moveAfter(self|integer $model)
 * Moves the model instance after $model.
 * If $model is empty, then moves the model instance to the beginning of his domain.
 *
 * @method null moveBefore(self|integer $model)
 * Moves the model instance before $model.
 *
 * @method integer[] getChildrenId(boolean $includeSelf = true, boolean $all = true)
 * Returns an array of instance IDs of child models. If $all is true, it also includes all sublevels.
 *
 * @method \yii\db\ActiveQueryInterface getChildren()
 * Returns ActiveQuery to get child models.
 *
 * @method \yii\db\ActiveQueryInterface getAllChildren(boolean $includeSelf = false)
 * Returns ActiveQuery to get instances of child models, including all sublevels.
 *
 * @method self getParent()
 * Returns an instance of the parent model.
 *
 * @method integer[] getParentsId(boolean $includeSelf = false)
 * Returns an array of instance IDs of parent models. Ordered by depth level.
 *
 * @method \yii\db\ActiveQueryInterface getParents(boolean $includeSelf = false)
 * Returns ActiveQuery to get instances of parent models.
 *
 * @method self getRoot()
 * Returns an instance of the root model.
 *
 * @method string getFullPath(string $delimeter = " → ", callable $callable = false)
 * Returns the full path of the model instance.
 * $callable is function to stringify model for output as path element.
 * Simple $callable example:
 * function($model, $isRoot, $isLeaf){
 *    return $model->title;
 * }
 *
 * @method self|false getJointParent(self $model, boolean $includeSelf = false)
 * Returns an instance of the joint parent of the current model and $model.
 *
 * @method null sortAlphabetically(integer $parentId = false, integer $direction = SORT_ASC)
 * Sorting model instances in alphabetical order.
 *
 * @method integer[] getTreeIds(boolean $includeSelf = true, boolean $includeParents = false)
 * Returns the identifiers of the child model instances, including all sublevels.
 * Also include instance IDs of the parent models, if $includeParents is true.
 *
 * @method \yii\db\ActiveQueryInterface getTree(boolean $includeSelf = true, boolean $includeParents = false)
 * Returns ActiveQuery to get child model instances, including all sublevels.
 * And instances of the parent models, if $includeParents is true.

License

MIT License


All versions of yii2-sortable-behaviour with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
yiisoft/yii2 Version ^2.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kl83/yii2-sortable-behaviour contains the following files

Loading the files please wait ....