Esempio n. 1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     /**
      * After validation event find out if default has to be set or not. Check if if current value
      * has default to 1, disabled the other default attributes.
      */
     $this->on(self::EVENT_BEFORE_INSERT, function ($event) {
         if ($this->is_default == 1) {
             self::updateAll(['is_default' => 0]);
         }
     });
     $this->on(self::EVENT_BEFORE_UPDATE, function ($event) {
         if ($this->is_default == 1) {
             $this->markAttributeDirty('is_default');
             self::updateAll(['is_default' => 0]);
         }
     });
 }
Esempio n. 2
0
 public function init()
 {
     parent::init();
     $this->on(self::EVENT_BEFORE_INSERT, [$this, 'eventBeforeInsert']);
     $this->on(self::EVENT_BEFORE_UPDATE, [$this, 'eventBeforeUpdate']);
 }
Esempio n. 3
0
 public function init()
 {
     parent::init();
     $this->on(self::EVENT_BEFORE_DELETE, [$this, 'eventBeforeDelete']);
 }
 public function init()
 {
     parent::init();
     $this->on(self::EVENT_BEFORE_INSERT, [$this, 'hashContent']);
     $this->on(self::EVENT_BEFORE_UPDATE, [$this, 'hashContent']);
 }
Esempio n. 5
0
 public function init()
 {
     parent::init();
     $this->on(self::EVENT_BEFORE_INSERT, [$this, 'encodePassword']);
 }
Esempio n. 6
0
 public function init()
 {
     parent::init();
     $this->on(self::EVENT_BEFORE_INSERT, [$this, 'beforeCreate']);
     $this->on(self::EVENT_BEFORE_VALIDATE, [$this, 'eventBeforeValidate']);
 }