Skip to content

Position

The Position trait is used to manage the position behavior of an object.

It provides methods to initialize the position behavior set and retrieve the position behavior object, and reorder the object's position in a list.

  • Full name: \Zemit\Mvc\Model\Traits\Position

Methods

initializePosition

Initializes the position behavior for the current object.

public initializePosition(array|null $options = null): void

Sets the position options and sets the position behavior accordingly.

Parameters:

Parameter Type Description
$options **array null**

Throws:


setPositionBehavior

Sets the position behavior for the current object.

public setPositionBehavior(\Zemit\Mvc\Model\Behavior\Position $positionBehavior): void

Parameters:

Parameter Type Description
$positionBehavior \Zemit\Mvc\Model\Behavior\Position The position behavior to be set.

getPositionBehavior

Retrieves the position behavior attached to the current object.

public getPositionBehavior(): \Zemit\Mvc\Model\Behavior\Position

Return Value:

The position behavior object.

Throws:

if the position behavior is not found.


reorder

Reorders the current object's position in the list.

public reorder(int|null $position = null, string|null $positionField = null): bool
  • Update position+1 done using afterSave event

Parameters:

Parameter Type Description
$position **int null**
$positionField **string null**

Return Value:

Returns true if the reorder operation was successful, false otherwise.

Throws: