Skip to content

Extension of the class yii\base\Behavior [We no longer maintain this repository]

Notifications You must be signed in to change notification settings

consultnn/yii2-behaviors

Repository files navigation

[We no longer maintain this repository]

Use consultnn/yii2-validators instead AttributeTypeBehavior

yii2-behaviors

Extension of the class yii\base\Behavior


###Class AttributeTypeBehavior to converts attribute for all simple types and mongoDb types.
Number and boolean type taken from the corresponding attribute validator

Example of a call from the model.
    public function behaviors()
    {
        return [
            [
                'class' => AttributeTypeBehavior::className(),
                'attributes' => [
                    '_id' => AttributeTypeBehavior::TYPE_MONGO_ID,
                    'attribute1' => [AttributeTypeBehavior::TYPE_ARRAY_OF => AttributeTypeBehavior::TYPE_INTEGER]
                ]
            ]
        ];
    }

Default events ActiveRecord::EVENT_BEFORE_INSERT, ActiveRecord::EVENT_BEFORE_UPDATE

Example add convert MongoDate type.

Add attributes => ['date' => 'MongoDate']
Add a method to the class AttributeTypeBehavior:

    private function setMongoDate(&$value)
    {
        $value = new \MongoDate(strtotime($value));
    }

###Class TreeViewBehavior to dynamically update the model attributes with the use of plug-in jstree Events ActiveRecord::EVENT_BEFORE_INSERT, ActiveRecord::EVENT_BEFORE_UPDATE, ActiveRecord::EVENT_BEFORE_DELETE

About

Extension of the class yii\base\Behavior [We no longer maintain this repository]

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages