Files
hdk-core/src/ConfigProvider.php
2023-04-13 23:38:38 +08:00

80 lines
3.0 KiB
PHP

<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Singularity\HDK\Core;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Framework\Logger\StdoutLogger;
use Hyperf\HttpServer\Contract\CoreMiddlewareInterface;
use Singularity\HDK\Core\Listener\EmailWillSentListener;
use Singularity\HDK\Core\Listener\SmsWillSentListener;
use Singularity\HDK\Core\Middleware\CommonCoreMiddleware;
class ConfigProvider
{
/** @phpstan-ignore-next-line */
public function __invoke(): array
{
/** @noinspection PhpUndefinedConstantInspection */
return [
// 合并到 config/autoload/dependencies.php 文件
'dependencies' => [
StdoutLoggerInterface::class => StdoutLogger::class,
CoreMiddlewareInterface::class => CommonCoreMiddleware::class
],
// 合并到 config/autoload/annotations.php 文件
'annotations' => [
'scan' => [
'paths' => [
__DIR__,
],
],
],
// 默认 Command 的定义,合并到 Hyperf\Contract\ConfigInterface 内,换个方式理解也就是与 config/autoload/commands.php 对应
'commands' => [
],
// 与 commands 类似
'listeners' => [
EmailWillSentListener::class,
SmsWillSentListener::class
],
// 组件默认配置文件,即执行命令后会把 source 的对应的文件复制为 destination 对应的的文件
'publish' => [
[
'id' => 'config',
'description' => 'The common config for HDK',
'source' => __DIR__ . '/../publish/common.php',
'destination' => BASE_PATH . '/config/autoload/common.php',
],
[
'id' => 'script',
'description' => 'The common script for HDK',
'source' => __DIR__ . '/../publish/scripts/docker-env.sh',
'destination' => BASE_PATH . '/scripts/docker-env.sh',
],
[
'id' => 'languages_cn',
'description' => 'The common error message for Chinese',
'source' => __DIR__ . '/../publish/languages/zh_CN/common_error.php',
'destination' => BASE_PATH . '/storage/languages/zh_CN/common_error.php',
],
[
'id' => 'languages_en',
'description' => 'The common error message for English',
'source' => __DIR__ . '/../publish/languages/en/common_error.php',
'destination' => BASE_PATH . '/storage/languages/en/common_error.php',
],
],
];
}
}