Skip to content

Latest commit

 

History

History
41 lines (32 loc) · 751 Bytes

07_tokenizable.md

File metadata and controls

41 lines (32 loc) · 751 Bytes

Tokenizable

The Tokenizable behavior automatically saves a random token string.

Configuration

array(
    'Model\Article' => array(
        'fields' => array(
            'field' => 'string',
        ),
        'behaviors' => array(
            array(
                'class' => 'Mongator\Behavior\Tokenizable', 
                'options' => array(
                    'length' => 5
                )
            ),
        ),
    ),
);

Options

  • field (default 'token'): field used to store the hash
  • length (default 10): the length of the token

Usage

$article = $mongator->create('Model\Article')->setTitle('Mongator')->save();

echo $article->getToken(); // 9b02d