36 lines
789 B
PHP
Executable File
36 lines
789 B
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
/**
|
|
* This file is part of the youyao/admin-api.
|
|
*
|
|
* (c) youyao <info@nuancebiotech.cn>
|
|
* This source file is subject to the license under the project that is bundled.
|
|
*/
|
|
use App\Model\User;
|
|
use Hyperf\Utils\ApplicationContext;
|
|
use Hyperf\Utils\Context;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
if (! function_exists('user')) {
|
|
/**
|
|
* 获取当前登录用户信息.
|
|
*/
|
|
function user(): ?User
|
|
{
|
|
return Context::get('user');
|
|
}
|
|
}
|
|
|
|
if (! function_exists('logger')) {
|
|
/**
|
|
* 获取日志.
|
|
* @param string $name
|
|
* @return LoggerInterface
|
|
*/
|
|
function logger($name = 'app'): LoggerInterface
|
|
{
|
|
return ApplicationContext::getContainer()->get(\Hyperf\Logger\LoggerFactory::class)->get($name);
|
|
}
|
|
}
|