This commit is contained in:
Yuri Kuznetsov
2021-04-21 15:19:37 +03:00
parent f9e34ce9d5
commit e183f39dfd
36 changed files with 215 additions and 104 deletions
+14 -5
View File
@@ -33,17 +33,26 @@ use Espo\ORM\Entity;
class UserData extends \Espo\Core\Repositories\Database
{
public function getByUserId(string $userId) : ?Entity
public function getByUserId(string $userId): ?Entity
{
$userData = $this->where(['userId' => $userId])->findOne();
$userData = $this
->where(['userId' => $userId])
->findOne();
if ($userData) return $userData;
if ($userData) {
return $userData;
}
$user = $this->getEntityManager()->getRepository('User')->getById($userId);
$user = $this->getEntityManager()
->getRepository('User')
->getById($userId);
if (!$user) return null;
if (!$user) {
return null;
}
$userData = $this->getNew();
$userData->set('userId', $userId);
$this->save($userData, [