PHP 클래스 OrderedBehavior

저자: Alexander Morland aka alkemann
상속: extends ModelBehavior
파일 보기 프로젝트 열기: croogo/croogo

공개 프로퍼티들

프로퍼티 타입 설명
$name

보호된 프로퍼티들

프로퍼티 타입 설명
$_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