/**
  * @return bool
  * @throws FileException
  */
 public function beforeDelete()
 {
     if (!parent::beforeDelete()) {
         return false;
     }
     // Delete file
     if (file_exists($this->getPath()) && !unlink($this->getPath())) {
         throw new FileException('Can not remove image thumb file `' . $this->getRelativePath() . '`.');
     }
     return true;
 }
示例#2
0
 /**
  * @param bool $insert
  * @param array $changedAttributes
  */
 public function afterSave($insert, $changedAttributes)
 {
     if ($insert && !$this->info) {
         $info = new UserInfo(['userUid' => $this->uid, 'firstName' => $this->name]);
         $info->userUid = $this->uid;
         $info->firstName = $this->name;
         $info->saveOrPanic();
     }
     parent::afterSave($insert, $changedAttributes);
 }