Class \Scrivo\SequenceNo

Class to manage the sequence (or order) numbers of various Scrivo entities.

Most Scrivo entitites like pages and lists items can be ordered manually. This is done by setting a sequence number field in the database for say all pages with a common parent.

Note that this ordering has nothing to do with database sequence generation used for generating ids.

Defined in: SequenceNo.php.


Constant summary

Name Description
MOVE_DOWN Constant to indicate that we want the entity to move one position down.
MOVE_FIRST Constant to indicate that we want to move the entity to the beginning.
MOVE_LAST Constant to indicate that we want to move the entity to the end.
MOVE_UP Constant to indicate that we want the entity to move one position up.

Method summary

Attr. Type Name / Description
public static

position($context, $tableName, $parentField, $id, $pos)

Move an entity to a given position.

private static

resequence($context, $tableName, $parentField, $id)

Regenerate all sequence numbers for a set of entities determined by the parent of the entity with the given $id.

 


Constants

MOVE_DOWN

Constant to indicate that we want the entity to move one position down.

Value: -2

MOVE_FIRST

Constant to indicate that we want to move the entity to the beginning.

Value: -3

MOVE_LAST

Constant to indicate that we want to move the entity to the end.

Value: -4

MOVE_UP

Constant to indicate that we want the entity to move one position up.

Value: -1


Methods

public static position(\Scrivo\Context $context, string $tableName, string $parentField, int $id, int $pos)

Move an entity to a given position.

Note that this is a postion number starting at 1, not a zero based index. Instead of an actual position number also one of \Scrivo\SequenceNo::MOVE_* constants can be used.

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

string $tableName

The table name for the entity to resequence.

string $parentField

The parent id field in the table for the entity to resequence.

int $id

The id of the entity to resequence.

int $pos

The new position of the entity to resequence, note that this is a postion number starting at 1, not a zero based index.

private static resequence(\Scrivo\Context $context, string $tableName, string $parentField, int $id)

Regenerate all sequence numbers for a set of entities determined by the parent of the entity with the given $id.

The new sequence numbers will start with and will have an offset of 2. Sequence numbers with a value of zero or less will not be updated.

Parameters:

Type Name Def. Description
\Scrivo\Context $context

A Scrivo context.

string $tableName

The table name for the entity to resequence.

string $parentField

The parent id field in the table for the entity to resequence.

int $id

The id of the entity to resequence.


Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013