PHP Class Baum\Move

Datei anzeigen Open project: gazsp/baum Class Usage Examples

Protected Properties

Property Type Description
$_bound1 integer Memoized 1st boundary.
$_bound2 integer Memoized 2nd boundary.
$_boundaries array Memoized boundaries array.
$dispatcher Illuminate\Events\Dispatcher The event dispatcher instance.
$node Node Node on which the move operation will be performed.
$position string Move target position, one of: child, left, right, root.
$target Destination node.

Public Methods

Method Description
__construct ( Node $node, Node | integer $target, string $position ) : void Create a new Move class instance.
getEventDispatcher ( ) : Illuminate\Events\Dispatcher Get the event dispatcher instance.
perform ( ) : Node Perform the move operation.
setEventDispatcher ( Illuminate\Events\Dispatcher $dispatcher = null ) : void Set the event dispatcher instance.
to ( Node $node, Node | integer $target, string $position ) : Node Easy static accessor for performing a move operation.
updateStructure ( ) : integer Runs the SQL query associated with the update of the indexes affected by the move operation.

Protected Methods

Method Description
applyLockBetween ( integer $lft, integer $rgt ) : void Applies a lock to the rows between the supplied index boundaries.
bound1 ( ) : integer Computes the boundary.
bound2 ( ) : integer Computes the other boundary.
boundaries ( ) : array Computes the boundaries array.
fireMoveEvent ( string $event, boolean $halt = true ) : mixed Fire the given move event for the model.
guardAgainstImpossibleMove ( ) : void Check wether the current move is possible and if not, rais an exception.
hasChange ( ) : boolean Check wether there should be changes in the downward tree structure.
parentId ( ) : integer Computes the new parent id for the node being moved.
promotingToRoot ( ) : boolean Check if we are promoting the provided instance to a root node.
quoteIdentifier ( mixed $value ) : string Quotes an identifier for being used in a database query.
resolveNode ( $node ) : Node Resolves suplied node. Basically returns the node unchanged if supplied parameter is an instance of \Baum\Node. Otherwise it will try to find the node in the database.

Method Details

__construct() public method

Create a new Move class instance.
public __construct ( Node $node, Node | integer $target, string $position ) : void
$node Node
$target Node | integer
$position string
return void

applyLockBetween() protected method

Applies a lock to the rows between the supplied index boundaries.
protected applyLockBetween ( integer $lft, integer $rgt ) : void
$lft integer
$rgt integer
return void

bound1() protected method

Computes the boundary.
protected bound1 ( ) : integer
return integer

bound2() protected method

TODO: Maybe find a better name for this... ¿?
protected bound2 ( ) : integer
return integer

boundaries() protected method

Computes the boundaries array.
protected boundaries ( ) : array
return array

fireMoveEvent() protected method

Fire the given move event for the model.
protected fireMoveEvent ( string $event, boolean $halt = true ) : mixed
$event string
$halt boolean
return mixed

getEventDispatcher() public static method

Get the event dispatcher instance.
public static getEventDispatcher ( ) : Illuminate\Events\Dispatcher
return Illuminate\Events\Dispatcher

guardAgainstImpossibleMove() protected method

Check wether the current move is possible and if not, rais an exception.
protected guardAgainstImpossibleMove ( ) : void
return void

hasChange() protected method

Check wether there should be changes in the downward tree structure.
protected hasChange ( ) : boolean
return boolean

parentId() protected method

Computes the new parent id for the node being moved.
protected parentId ( ) : integer
return integer

perform() public method

Perform the move operation.
public perform ( ) : Node
return Node

promotingToRoot() protected method

Check if we are promoting the provided instance to a root node.
protected promotingToRoot ( ) : boolean
return boolean

quoteIdentifier() protected method

Quotes an identifier for being used in a database query.
protected quoteIdentifier ( mixed $value ) : string
$value mixed
return string

resolveNode() protected method

Resolves suplied node. Basically returns the node unchanged if supplied parameter is an instance of \Baum\Node. Otherwise it will try to find the node in the database.
protected resolveNode ( $node ) : Node
return Node

setEventDispatcher() public static method

Set the event dispatcher instance.
public static setEventDispatcher ( Illuminate\Events\Dispatcher $dispatcher = null ) : void
$dispatcher Illuminate\Events\Dispatcher
return void

to() public static method

Easy static accessor for performing a move operation.
public static to ( Node $node, Node | integer $target, string $position ) : Node
$node Node
$target Node | integer
$position string
return Node

updateStructure() public method

Runs the SQL query associated with the update of the indexes affected by the move operation.
public updateStructure ( ) : integer
return integer

Property Details

$_bound1 protected_oe property

Memoized 1st boundary.
protected int $_bound1
return integer

$_bound2 protected_oe property

Memoized 2nd boundary.
protected int $_bound2
return integer

$_boundaries protected_oe property

Memoized boundaries array.
protected array $_boundaries
return array

$dispatcher protected_oe static_oe property

The event dispatcher instance.
protected static Dispatcher,Illuminate\Events $dispatcher
return Illuminate\Events\Dispatcher

$node protected_oe property

Node on which the move operation will be performed.
protected Node,Baum $node
return Node

$position protected_oe property

Move target position, one of: child, left, right, root.
protected string $position
return string

$target protected_oe property

Destination node.
protected $target