Exemplo n.º 1
0
 /**
  * Create a new account and initialize it
  * @param string $company
  * @param string $mobile
  * @param string $priceType
  * @throws ServerErrorHttpException
  * @return MongoId
  */
 public static function create($company, $phone, $name, $priceType = self::PRICE_TYPE_FREE)
 {
     $account = new Account();
     $account->priceType = $priceType;
     $account->company = $company;
     $account->phone = $phone;
     $account->name = $name;
     $account->availableExtMods = ['member', 'product', 'microsite', 'helpdesk'];
     // add 4 basic mods into extensions #3191
     $account->generateKey();
     $enabledMods = Yii::$app->params['coreMods'];
     $result = Yii::$app->extModule->getMergedConfig($enabledMods);
     $account->menus = $result['menus'];
     $account->mods = $result['mods'];
     if ($account->save()) {
         self::afterCreateAccount($account);
         return $account->_id;
     }
     throw new ServerErrorHttpException("Save account failed");
 }