[*] корректировки README.md и мелкие правки
This commit is contained in:
1 parent
8c208174c2
commit
4cd24629ab
3 files changed
+36
-174
No files matched your search
@@ -105,7 +105,7 @@
|
||||
];
|
||||
|
||||
$userId = User::getCurrentUserId();
|
||||
if (!empty($userId)) {
|
||||
if ($userId !== null) {
|
||||
$objectUser = new User($userId);
|
||||
$env['userId'] = $objectUser->getId();
|
||||
$env['userLogin'] = $objectUser->getLogin();
|
||||
@@ -135,38 +135,4 @@
|
||||
|
||||
return $result ?: 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Метод сохранения логов в Sentry
|
||||
*
|
||||
* @param string $sentryMessage Сообщение, передаваемое в Sentry и отображающееся как заголовок Issue
|
||||
* @param string $sentryErrorLevel Уровень события Sentry (FATAL, ERROR, WARNING, INFO, DEBUG)
|
||||
* @param array $sentryData Массив данных лога
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function logToSentry(
|
||||
string $sentryMessage,
|
||||
string $sentryErrorLevel = 'DEBUG',
|
||||
array $sentryData = []
|
||||
): bool {
|
||||
$sentryErrorLevelArray = ['FATAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'];
|
||||
|
||||
if (empty(trim($sentryMessage))
|
||||
|| !in_array($sentryErrorLevel, $sentryErrorLevelArray)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_array($sentryData) && count($sentryData) > 0) {
|
||||
\Sentry\configureScope(function (\Sentry\State\Scope $sentryScope) use ($sentryData) {
|
||||
foreach ($sentryData as $paramName => $paramValue) {
|
||||
$sentryScope->setExtra($paramName, $paramValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
\Sentry\captureMessage($sentryMessage, \Sentry\Severity::$sentryErrorLevel());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Roman Grinko <rsgrinko@gmail.com>
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Класс реестра
|
||||
*/
|
||||
|
||||
namespace Core\Helpers;
|
||||
|
||||
class Registry
|
||||
{
|
||||
private static $_storage = [];
|
||||
|
||||
/**
|
||||
* Установка значения
|
||||
*/
|
||||
public static function set($key, $value)
|
||||
{
|
||||
return self::$_storage[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение значения
|
||||
*/
|
||||
public static function get($key, $default = null)
|
||||
{
|
||||
return (isset(self::$_storage[$key])) ? self::$_storage[$key] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Удаление
|
||||
*/
|
||||
public static function del($key): void
|
||||
{
|
||||
unset(self::$_storage[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Очистка
|
||||
*/
|
||||
public static function flush(): void
|
||||
{
|
||||
self::$_storage = [];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user