Exemple #1
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['tree' => ['class' => TreeBehavior::className(), 'showAttrName' => 'name'], 'treeWave' => ['class' => TreeWaveBehavior::className(), 'topDownAttrs' => ['status' => self::STATUS_HIDDEN], 'bottomUpAttrs' => ['status' => self::STATUS_SHOW]], ['class' => AttributeBehavior::className(), 'attributes' => [self::EVENT_BEFORE_INSERT => ['create_time' => time(), 'create_user_id' => Yii::$app->user->id, 'auth_item' => ['handle' => 'join', 'args' => ['joinAttributes' => ['app', 'module', 'controller', 'action']], 'when' => function ($model, $event) {
         return $model->type == self::AUTH_MENU;
     }], 'auth_rules' => ['handle' => 'implode']], self::EVENT_BEFORE_UPDATE => ['auth_item' => ['handle' => 'join', 'args' => ['joinAttributes' => ['app', 'module', 'controller', 'action']], 'when' => function ($model, $event) {
         return $model->type == self::AUTH_MENU;
     }], 'auth_rules' => ['handle' => 'implode']], self::EVENT_AFTER_FIND => ['auth_rules' => ['handle' => 'explode']]]], MenuPermissionBehavior::className()];
 }
Exemple #2
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [RoleBehavior::className(), ['class' => AttributeBehavior::className(), 'attributes' => [self::EVENT_BEFORE_INSERT => ['create_time' => function ($event) {
         return time();
     }]]]];
 }