/** * @return User */ public function getUser() { if ($this->userId === null) { return null; } if (SystemUser::isSystemUserId($this->userId)) { return SystemUser::create(); } if (isset($this->user) && $this->userId == $this->user->getId()) { return $this->user; } $this->user = User::loadById($this->userId); return $this->user; }
/** * @internal * @param $userId * @param User $currentFieldValue * @return User|EmptyUser|SystemUser */ public static function getModelForReferenceField($userId, User $currentFieldValue = null) { if ($userId === null) { return EmptyUser::create(); } if (SystemUser::isSystemUserId($userId)) { return SystemUser::create(); } if (isset($currentFieldValue) && $userId == $currentFieldValue->getId()) { return $currentFieldValue; } $user = User::loadById($userId); if (!$user) { return EmptyUser::create(); } return $user; }
/** * @return \Bitrix\Disk\User|null */ private function getUser() { if ($this->user !== null) { return $this->user; } $this->user = UserModel::loadById($this->entityId); if (!$this->user) { $this->user = SystemUser::create(); } return $this->user; }
protected static function checkRequiredInputParams(array $inputParams, array $required) { foreach ($required as $item) { if (!isset($inputParams[$item]) || !$inputParams[$item] && !(is_string($inputParams[$item]) && strlen($inputParams[$item]))) { //todo create validator! this is trash. if ($item === 'CREATED_BY' || $item === 'UPDATED_BY' || $item === 'DELETED_BY') { //0 - valid value for above fields if (SystemUser::isSystemUserId($inputParams[$item])) { return; } } if ($item === 'FILE_SIZE') { //possible 0 for FILE size if (is_numeric($inputParams[$item]) && (int) $inputParams[$item] === 0) { return; } } throw new ArgumentException("Required params: { {$item} }"); } } return; }