PHP Класс OrderedBehavior

Автор: Alexander Morland aka alkemann
Наследование: extends ModelBehavior
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$name

Защищенные свойства (Protected)

Свойство Тип Описание
$_defaults foreign_key : (string) The field to identify one SET by. Each set has their own order (ie they start at 1). Set to FALSE to not use this feature (and use only 1 set)

Открытые методы

Метод Описание
afterDelete ( Model $Model )
beforeDelete ( Model $Model, $cascade = true )
beforeSave ( Model $Model, $options = [] ) Sets the weight for new items so they end up at end
isFirst ( Model $Model, Int $id = null ) : Boolean, Returns true if the specified item is the first item
isLast ( Model $Model, Int $id = null ) : Boolean, Returns true if the specified item is the last item
moveDown ( Model $Model, mixed $id = null, mixed $number = 1 ) : boolean Reorder the node, by moving it $number spaces down. Defaults to 1
moveTo ( Model $Model, integer $id = null, integer $newWeight = null ) : boolean Moving a node to specific weight, it will shift the rest of the table to make room.
moveUp ( Model $Model, mixed $id = null, mixed $number = 1 ) : boolean Reorder the node, by moving it $number spaces up. Defaults to 1
removefromlist ( Model $Model, integer $id ) : boolean Removing an item from the list means to set its field to 0 and updating the other items to be "complete"
resetWeights ( Model $Model ) : boolean This will create weights based on display field. The purpose of the method is to create weights for tables that existed before this behavior was added.
setup ( Model $Model, $config = [] )
sortBy ( Model $Model, array $order, mixed $foreignKey = null ) Take in an order array and sorts the list based on that order specification and creates new weights for it. If no foreign key is supplied, all lists will be sorted.

Защищенные методы

Метод Описание
_all ( Model $Model )
_findbyweight ( Model $Model, $weight )
_highest ( Model $Model )
_next ( Model $Model )
_previous ( Model $Model )
_read ( Model $Model, $id )

Описание методов

_all() защищенный Метод

protected _all ( Model $Model )
$Model Model

_findbyweight() защищенный Метод

protected _findbyweight ( Model $Model, $weight )
$Model Model

_highest() защищенный Метод

protected _highest ( Model $Model )
$Model Model

_next() защищенный Метод

protected _next ( Model $Model )
$Model Model

_previous() защищенный Метод

protected _previous ( Model $Model )
$Model Model

_read() защищенный Метод

protected _read ( Model $Model, $id )
$Model Model

afterDelete() публичный Метод

public afterDelete ( Model $Model )
$Model Model

beforeDelete() публичный Метод

public beforeDelete ( Model $Model, $cascade = true )
$Model Model

beforeSave() публичный Метод

Sets the weight for new items so they end up at end
public beforeSave ( Model $Model, $options = [] )
$Model Model

isFirst() публичный Метод

Returns true if the specified item is the first item
public isFirst ( Model $Model, Int $id = null ) : Boolean,
$Model Model
$id Int
Результат Boolean,

isLast() публичный Метод

Returns true if the specified item is the last item
public isLast ( Model $Model, Int $id = null ) : Boolean,
$Model Model
$id Int
Результат Boolean,

moveDown() публичный Метод

If the node is the last node (or less then $number spaces from last) this method will return false.
public moveDown ( Model $Model, mixed $id = null, mixed $number = 1 ) : boolean
$Model Model
$id mixed The ID of the record to move
$number mixed how many places to move the node or true to move to last position
Результат boolean true on success, false on failure

moveTo() публичный Метод

Moving a node to specific weight, it will shift the rest of the table to make room.
public moveTo ( Model $Model, integer $id = null, integer $newWeight = null ) : boolean
$Model Model
$id integer The id of the node to move
$newWeight integer the new weight of the node
Результат boolean True of move successful

moveUp() публичный Метод

If the node is the first node (or less then $number spaces from first) this method will return false.
public moveUp ( Model $Model, mixed $id = null, mixed $number = 1 ) : boolean
$Model Model
$id mixed The ID of the record to move
$number mixed how many places to move the node or true to move to last position
Результат boolean true on success, false on failure

removefromlist() публичный Метод

Removing an item from the list means to set its field to 0 and updating the other items to be "complete"
public removefromlist ( Model $Model, integer $id ) : boolean
$Model Model
$id integer
Результат boolean

resetWeights() публичный Метод

This will create weights based on display field. The purpose of the method is to create weights for tables that existed before this behavior was added.
public resetWeights ( Model $Model ) : boolean
$Model Model
Результат boolean success

setup() публичный Метод

public setup ( Model $Model, $config = [] )
$Model Model

sortBy() публичный Метод

Take in an order array and sorts the list based on that order specification and creates new weights for it. If no foreign key is supplied, all lists will be sorted.
public sortBy ( Model $Model, array $order, mixed $foreignKey = null )
$Model Model
$order array
$foreignKey mixed $returns boolean true if successfull

Описание свойств

$_defaults защищенное свойство

foreign_key : (string) The field to identify one SET by. Each set has their own order (ie they start at 1). Set to FALSE to not use this feature (and use only 1 set)
protected $_defaults

$name публичное свойство

public $name