/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/kdf/KApiKey.php
89 строк
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\kdf; use common\behaviors\UniqueHashBehavior; use common\models\ApiWhiteListIp; use Yii; use yii\helpers\ArrayHelper; /** * Классификатор - список API ключёй приложений * * @property string $title Название приложения * @property string $api_key API ключ приложения * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2019 */ class KApiKey extends \common\kdf\base\BaseKdf { const FRONT = 1; const ERP = 2; const MEMOQ = 2; const API = 4; /** * {@inheritdoc} */ public static function tableName() { return 'k_api_key'; } /** * {@inheritdoc} */ public function rules() { return ArrayHelper::merge(parent::rules(), [ [['title'], 'required'], [['title'], 'string', 'max' => 200], [['api_key'], 'string', 'max' => 32], [['api_key'], 'unique'], ]); } /** * {@inheritdoc} */ public function behaviors() { return ArrayHelper::merge(parent::behaviors(), [ 'UniqueHashBehavior' => [ 'class' => UniqueHashBehavior::class, 'hashAttribute' => 'api_key', 'hashLength' => 32, 'type' => 'hexdec' ], ]); } /** * {@inheritdoc} */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), [ 'title' => Yii::t('app', 'Title'), 'api_key' => Yii::t('app', 'API key'), ]); } /** * @return \yii\db\ActiveQuery */ public function getWhiteListIp() { return $this->hasMany(ApiWhiteListIp::class, ['api_key_id' => 'id']); } /** * Является текущее приложение ERP ? * @return bool */ public function isErp() { return $this->id == self::ERP; } }