PHP Class OrderedBehavior

Author: Alexander Morland aka alkemann
Inheritance: extends ModelBehavior
Afficher le fichier Open project: croogo/croogo

Méthodes publiques

Свойство Type Description
$name

Protected Properties

Свойство Type Description
$_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)

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
_all ( Model $Model )
_findbyweight ( Model $Model, $weight )
_highest ( Model $Model )
_next ( Model $Model )
_previous ( Model $Model )
_read ( Model $Model, $id )

Method Details

_all() protected méthode

protected _all ( Model $Model )
$Model Model

_findbyweight() protected méthode

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

_highest() protected méthode

protected _highest ( Model $Model )
$Model Model

_next() protected méthode

protected _next ( Model $Model )
$Model Model

_previous() protected méthode

protected _previous ( Model $Model )
$Model Model

_read() protected méthode

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

afterDelete() public méthode

public afterDelete ( Model $Model )
$Model Model

beforeDelete() public méthode

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

beforeSave() public méthode

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

isFirst() public méthode

Returns true if the specified item is the first item
public isFirst ( Model $Model, Int $id = null ) : Boolean,
$Model Model
$id Int
Résultat Boolean,

isLast() public méthode

Returns true if the specified item is the last item
public isLast ( Model $Model, Int $id = null ) : Boolean,
$Model Model
$id Int
Résultat Boolean,

moveDown() public méthode

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
Résultat boolean true on success, false on failure

moveTo() public méthode

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
Résultat boolean True of move successful

moveUp() public méthode

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
Résultat boolean true on success, false on failure

removefromlist() public méthode

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
Résultat boolean

resetWeights() public méthode

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
Résultat boolean success

setup() public méthode

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

sortBy() public méthode

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

Property Details

$_defaults protected_oe property

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_oe property

public $name