Handy helper class to keep manually sorted lists more manageable.

 Methods

Create a new instance.

__construct(\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface $models, \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface $siblings, string $sortedBy, \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $previousModel) 

Parameters

$models

\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

The collection containing the models to be inserted.

$siblings

\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

The collection containing the models that are siblings.

$sortedBy

string

The property that is used for sorting.

$previousModel

\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

The model preceding the target position of the first model from the collection.

Get the collection containing the models to be inserted.

getModels() : \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

Get the model preceding the target position of the first model from the collection.

getPreviousModel() : \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface | null

Get the name of the sorting property.

getSortingProperty() : string

Returns

string

Set the collection containing the models to be inserted.

setModels(\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface $models) : \ContaoCommunityAlliance\DcGeneral\Controller\SortingManager

Parameters

$models

\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

The collection containing the models to be inserted.

Returns

Set the model preceding the target position of the first model from the collection.

setPreviousModel(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface|null $previousModel) : \ContaoCommunityAlliance\DcGeneral\Controller\SortingManager

Parameters

$previousModel

\ContaoCommunityAlliance\DcGeneral\Data\ModelInterfacenull

The model preceding the target position of the first model from the collection.

Returns

Set the collection containing the models that are siblings.

setSiblings(\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface $siblings) : \ContaoCommunityAlliance\DcGeneral\Controller\SortingManager

Parameters

$siblings

\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

The collection containing the models that are siblings.

Returns

Set the name of the sorting property.

setSortingProperty(string $sortingProperty) : \ContaoCommunityAlliance\DcGeneral\Controller\SortingManager

Parameters

$sortingProperty

string

The property that is used for sorting.

Returns

Calculate the resulting list.

calculate() : void

Exceptions

\RuntimeException When no sorting property has been defined.

Retrieve the ids of the models.

getModelIds() : array

Returns

array

Scan through the sibling list to the position we want to insert at.

scanToDesiredPosition() : void

Determine delta value.

determineDelta() : float | int
Delta value will be between 2 and a multiple 128 which is large enough to contain all models being moved.

Returns

floatint

Update the sorting property values of all models.

updateSorting() : void

 Properties

 

Temporary marker containing the model currently in scope.

$marker : null | \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface
 

The collection containing the models to be inserted.

$models : \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface
 

The current position value.

$position : int
 

The model preceding the target position of the first model from the collection.

$previousModel : null | \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface
   

The collection containing the models that are siblings.

$siblings : \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface
 

The collection containing the models that are siblings (working copy).

$siblingsCopy : \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface
 

The property that is used for sorting.

$sortingProperty : string