PHP Class Tools\Model\Behavior\BitmaskedBehavior

An implementation of bitwise masks for row-level operations. You can submit/register flags in different ways. The easiest way is using a static model function. It should contain the bits like so (starting with 1): 1 => w, 2 => x, 4 => y, 8 => z, ... (bits as keys - names as values) The order doesn't matter, as long as no bit is used twice. The theoretical limit for a 64-bit integer would be 64 bits (2^64). But if you actually seem to need more than a hand full you obviously do something wrong and should better use a joined table etc.
Inheritance: extends Cake\ORM\Behavior
Afficher le fichier Open project: dereuromark/cakephp-tools Class Usage Examples

Protected Properties

Свойство Type Description
$_defaultConfig array Default config

Méthodes publiques

Méthode Description
beforeFind ( Cake\Event\Event $event, Query $query ) : void
beforeRules ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options ) : void
beforeSave ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options ) : void
containsBit ( integer | array $bits ) : array
containsNotBit ( integer | array $bits ) : array
decodeBitmask ( integer $value ) : array
encodeBitmask ( array $value, mixed $defaultValue = null ) : integer
encodeBitmaskConditions ( Query $query ) : void
encodeBitmaskData ( Cake\ORM\Entity $entity ) : void
initialize ( array $config = [] ) : void Behavior configuration
isBit ( integer | array $bits ) : array
isNotBit ( integer | array $bits ) : array

Méthodes protégées

Méthode Description
_containsBit ( integer | array $bits, boolean $contain = true ) : array

Method Details

_containsBit() protected méthode

protected _containsBit ( integer | array $bits, boolean $contain = true ) : array
$bits integer | array
$contain boolean
Résultat array SQL snippet.

beforeFind() public méthode

public beforeFind ( Cake\Event\Event $event, Query $query ) : void
$event Cake\Event\Event
$query Cake\ORM\Query
Résultat void

beforeRules() public méthode

public beforeRules ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options ) : void
$event Cake\Event\Event
$entity Cake\ORM\Entity
$options ArrayObject
Résultat void

beforeSave() public méthode

public beforeSave ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options ) : void
$event Cake\Event\Event
$entity Cake\ORM\Entity
$options ArrayObject
Résultat void

containsBit() public méthode

public containsBit ( integer | array $bits ) : array
$bits integer | array
Résultat array SQL snippet.

containsNotBit() public méthode

public containsNotBit ( integer | array $bits ) : array
$bits integer | array
Résultat array SQL snippet.

decodeBitmask() public méthode

public decodeBitmask ( integer $value ) : array
$value integer Bitmask.
Résultat array Bitmask array (from DB to APP).

encodeBitmask() public méthode

public encodeBitmask ( array $value, mixed $defaultValue = null ) : integer
$value array Bitmask array.
$defaultValue mixed Default bitmask value.
Résultat integer Bitmask (from APP to DB).

encodeBitmaskConditions() public méthode

public encodeBitmaskConditions ( Query $query ) : void
$query Cake\ORM\Query
Résultat void

encodeBitmaskData() public méthode

public encodeBitmaskData ( Cake\ORM\Entity $entity ) : void
$entity Cake\ORM\Entity
Résultat void

initialize() public méthode

Behavior configuration
public initialize ( array $config = [] ) : void
$config array
Résultat void

isBit() public méthode

public isBit ( integer | array $bits ) : array
$bits integer | array
Résultat array SQL snippet.

isNotBit() public méthode

public isNotBit ( integer | array $bits ) : array
$bits integer | array
Résultat array SQL snippet.

Property Details

$_defaultConfig protected_oe property

Default config
protected array $_defaultConfig
Résultat array