Class mdm\autonumber\Behavior

Inheritancemdm\autonumber\Behavior » yii\behaviors\AttributeBehavior » yii\base\Behavior » yii\base\Object
Available since version1.0

Behavior use to generate formated autonumber.

Use at ActiveRecord behavior

public function behavior()
{
    return [
        ...
        [
            'class' => 'mdm\autonumber\Behavior',
            'value' => date('Ymd').'.?', // ? will replace with generated number
            'digit' => 6, // specify this if you need leading zero for number
        ]
    ]
}

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$attribute string mdm\autonumber\Behavior
$attributes array List of attributes that are to be automatically filled with the value specified via $value. yii\behaviors\AttributeBehavior
$digit integer Digit number of auto number mdm\autonumber\Behavior
$group mixed mdm\autonumber\Behavior
$owner yii\base\Component The owner of this behavior yii\base\Behavior
$unique boolean mdm\autonumber\Behavior
$value mixed The value that will be assigned to the current attributes. yii\behaviors\AttributeBehavior

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\Object
__construct() Constructor. yii\base\Object
__get() Returns the value of an object property. yii\base\Object
__isset() Checks if the named property is set (not null). yii\base\Object
__set() Sets value of an object property. yii\base\Object
__unset() Sets an object property to null. yii\base\Object
attach() Attaches the behavior object to the component. yii\base\Behavior
canGetProperty() Returns a value indicating whether a property can be read. yii\base\Object
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Object
className() Returns the fully qualified name of this class. yii\base\Object
detach() Detaches the behavior object from the component. yii\base\Behavior
evaluateAttributes() Evaluates the attribute value and assigns it to the current attributes. yii\behaviors\AttributeBehavior
events() Declares event handlers for the $owner's events. yii\behaviors\AttributeBehavior
hasMethod() Returns a value indicating whether a method is defined. yii\base\Object
hasProperty() Returns a value indicating whether a property is defined. yii\base\Object
init() Initializes the object. mdm\autonumber\Behavior

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
getValue() Returns the value of the current attributes. mdm\autonumber\Behavior

Property Details

$attribute public property
$digit public property
integer $digit null

Digit number of auto number

$group public property
mixed $group null
$unique public property

Method Details

getValue() protected method

Returns the value of the current attributes.

This method is called by evaluateAttributes(). Its return value will be assigned to the attributes corresponding to the triggering event.

mixed getValue$event )
$event yii\base\Event

The event that triggers the current attribute updating.

return mixed

The attribute value

init() public method

Initializes the object.

This method is invoked at the end of the constructor after the object is initialized with the given configuration.

void init( )