public static function add($word, $extension)
    {
        $headword = Headword::find()->where(['word' => $word, 'extension_guid' => $extension->guid])->one();
        if ($headword) {
            throw new InvalidParamException('The word: `' . $word . '` has existed.');
        }
        $headword = new Headword(['word' => $word, 'extension' => $extension]);
        $transaction = $headword->getDb()->beginTransaction();
        try {
            if (!$headword->save()) {
                if (YII_ENV !== YII_ENV_PROD) {
                    var_dump($headword->errors);
                }
                throw new InvalidParamException("Failed to add headword.");
            }
            $transaction->commit();
        } catch (\Exception $ex) {
            $transaction->rollBack();
            throw $ex;
        }
        return $headword;
    }