mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Первичное портирование логики сервера авторизации с PhalconPHP на Yii2
This commit is contained in:
@@ -25,18 +25,21 @@ class PrimaryKeyValueBehavior extends Behavior {
|
||||
}
|
||||
|
||||
public function setPrimaryKeyValue() : bool {
|
||||
$owner = $this->owner;
|
||||
if ($owner->getPrimaryKey() === null) {
|
||||
do {
|
||||
$key = $this->generateValue();
|
||||
} while ($this->isValueExists($key));
|
||||
|
||||
$owner->{$this->getPrimaryKeyName()} = $key;
|
||||
if ($this->owner->getPrimaryKey() === null) {
|
||||
$this->refreshPrimaryKeyValue();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function refreshPrimaryKeyValue() {
|
||||
do {
|
||||
$key = $this->generateValue();
|
||||
} while ($this->isValueExists($key));
|
||||
|
||||
$this->owner->{$this->getPrimaryKeyName()} = $key;
|
||||
}
|
||||
|
||||
protected function generateValue() : string {
|
||||
return (string)call_user_func($this->value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user