v7.0.0-beta.2 release
This commit is contained in:
1 parent
6595fd0eb5
commit
fa8eba7a0d
1165 files changed
+107118
-762127
No files matched your search
@@ -20,6 +20,22 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
// NOTE: Faker 부재 시 FakerShim 대체는 app/Support/SampleData/bootstrap.php 에서 처리
|
||||
// (composer autoload.files 진입점 — vendor/autoload.php 로드 직후 실행되어
|
||||
// Laravel 의 fake() 헬퍼 정의 시점에 \Faker\Factory 가 이미 alias 되어 있음)
|
||||
|
||||
// 알림 발송 공통 디스패처 — 채널 독립 발송 + 발송 전후 G7 훅 실행
|
||||
$this->app->singleton(
|
||||
\Illuminate\Notifications\ChannelManager::class,
|
||||
fn ($app) => new \App\Notifications\NotificationChannelManager($app)
|
||||
);
|
||||
|
||||
// 채널 Readiness 검증 — 미설정 채널 발송 사전 차단
|
||||
$this->app->singleton(
|
||||
\App\Contracts\Notifications\ChannelReadinessCheckerInterface::class,
|
||||
\App\Services\ChannelReadinessService::class
|
||||
);
|
||||
|
||||
// TODO: TemplateManagerInterface 바인딩을 추가해야 함
|
||||
|
||||
// PluginManagerInterface 바인딩
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Contracts\Extension\CacheInterface;
|
||||
use App\Contracts\Extension\HookListenerInterface;
|
||||
use App\Contracts\UniqueIdServiceInterface;
|
||||
use App\Contracts\Extension\ModuleSettingsInterface;
|
||||
use App\Contracts\Extension\StorageInterface;
|
||||
use App\Contracts\Extension\TemplateManagerInterface;
|
||||
use App\Contracts\Repositories\ActivityLogRepositoryInterface;
|
||||
use App\Contracts\Repositories\AttachmentRepositoryInterface;
|
||||
use App\Contracts\Repositories\ConfigRepositoryInterface;
|
||||
@@ -13,10 +14,12 @@ use App\Contracts\Repositories\LayoutExtensionRepositoryInterface;
|
||||
use App\Contracts\Repositories\LayoutPreviewRepositoryInterface;
|
||||
use App\Contracts\Repositories\LayoutRepositoryInterface;
|
||||
use App\Contracts\Repositories\LayoutVersionRepositoryInterface;
|
||||
use App\Contracts\Repositories\MailSendLogRepositoryInterface;
|
||||
use App\Contracts\Repositories\MailTemplateRepositoryInterface;
|
||||
use App\Contracts\Repositories\MenuRepositoryInterface;
|
||||
use App\Contracts\Repositories\ModuleRepositoryInterface;
|
||||
use App\Contracts\Repositories\NotificationDefinitionRepositoryInterface;
|
||||
use App\Contracts\Repositories\NotificationLogRepositoryInterface;
|
||||
use App\Contracts\Repositories\NotificationRepositoryInterface;
|
||||
use App\Contracts\Repositories\NotificationTemplateRepositoryInterface;
|
||||
use App\Contracts\Repositories\PasswordResetTokenRepositoryInterface;
|
||||
use App\Contracts\Repositories\PermissionRepositoryInterface;
|
||||
use App\Contracts\Repositories\PluginRepositoryInterface;
|
||||
@@ -27,11 +30,14 @@ use App\Contracts\Repositories\SystemConfigRepositoryInterface;
|
||||
use App\Contracts\Repositories\TemplateRepositoryInterface;
|
||||
use App\Contracts\Repositories\UserConsentRepositoryInterface;
|
||||
use App\Contracts\Repositories\UserRepositoryInterface;
|
||||
use App\Contracts\UniqueIdServiceInterface;
|
||||
use App\Extension\CoreVersionChecker;
|
||||
use App\Extension\ExtensionManager;
|
||||
use App\Extension\HookListenerRegistrar;
|
||||
use App\Extension\HookManager;
|
||||
use App\Extension\ModuleManager;
|
||||
use App\Extension\PluginManager;
|
||||
use App\Extension\Cache\CoreCacheDriver;
|
||||
use App\Extension\Storage\CoreStorageDriver;
|
||||
use App\Extension\TemplateManager;
|
||||
use App\Repositories\ActivityLogRepository;
|
||||
@@ -41,10 +47,12 @@ use App\Repositories\LayoutExtensionRepository;
|
||||
use App\Repositories\LayoutPreviewRepository;
|
||||
use App\Repositories\LayoutRepository;
|
||||
use App\Repositories\LayoutVersionRepository;
|
||||
use App\Repositories\MailSendLogRepository;
|
||||
use App\Repositories\MailTemplateRepository;
|
||||
use App\Repositories\MenuRepository;
|
||||
use App\Repositories\ModuleRepository;
|
||||
use App\Repositories\NotificationDefinitionRepository;
|
||||
use App\Repositories\NotificationLogRepository;
|
||||
use App\Repositories\NotificationRepository;
|
||||
use App\Repositories\NotificationTemplateRepository;
|
||||
use App\Repositories\PasswordResetTokenRepository;
|
||||
use App\Repositories\PermissionRepository;
|
||||
use App\Repositories\PluginRepository;
|
||||
@@ -56,9 +64,9 @@ use App\Repositories\TemplateRepository;
|
||||
use App\Repositories\UserConsentRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\AttachmentService;
|
||||
use App\Services\UniqueIdService;
|
||||
use App\Services\DriverRegistryService;
|
||||
use App\Services\LayoutExtensionService;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Services\UniqueIdService;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
@@ -67,6 +75,14 @@ use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class CoreServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* registerDynamicHooks() 메서드를 가진 리스너 클래스 목록.
|
||||
* boot 후반부(DB 접근 가능 시점)에서 일괄 실행됩니다.
|
||||
*
|
||||
* @var array<string>
|
||||
*/
|
||||
private array $deferredDynamicListeners = [];
|
||||
|
||||
/**
|
||||
* 코어 서비스들을 등록합니다.
|
||||
*/
|
||||
@@ -160,8 +176,10 @@ class CoreServiceProvider extends ServiceProvider
|
||||
$this->app->bind(TemplateRepositoryInterface::class, TemplateRepository::class);
|
||||
$this->app->bind(UserConsentRepositoryInterface::class, UserConsentRepository::class);
|
||||
$this->app->bind(UserRepositoryInterface::class, UserRepository::class);
|
||||
$this->app->bind(MailTemplateRepositoryInterface::class, MailTemplateRepository::class);
|
||||
$this->app->bind(MailSendLogRepositoryInterface::class, MailSendLogRepository::class);
|
||||
$this->app->bind(NotificationDefinitionRepositoryInterface::class, NotificationDefinitionRepository::class);
|
||||
$this->app->bind(NotificationLogRepositoryInterface::class, NotificationLogRepository::class);
|
||||
$this->app->bind(NotificationRepositoryInterface::class, NotificationRepository::class);
|
||||
$this->app->bind(NotificationTemplateRepositoryInterface::class, NotificationTemplateRepository::class);
|
||||
|
||||
// UniqueIdService 바인딩
|
||||
$this->app->singleton(UniqueIdServiceInterface::class, UniqueIdService::class);
|
||||
@@ -172,6 +190,12 @@ class CoreServiceProvider extends ServiceProvider
|
||||
->give(function () {
|
||||
return new CoreStorageDriver(config('attachment.disk', 'local'));
|
||||
});
|
||||
|
||||
// 코어 서비스용 CoreCacheDriver 바인딩
|
||||
// Phase 7(이관)에서 각 서비스에 CacheInterface DI 추가 시 when() 목록 확대 예정
|
||||
$this->app->bind(CacheInterface::class, function () {
|
||||
return new CoreCacheDriver(config('cache.default'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +253,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
});
|
||||
|
||||
// 템플릿 매니저 인터페이스 바인딩
|
||||
$this->app->singleton(\App\Contracts\Extension\TemplateManagerInterface::class, function ($app) {
|
||||
$this->app->singleton(TemplateManagerInterface::class, function ($app) {
|
||||
return $app->make(TemplateManager::class);
|
||||
});
|
||||
}
|
||||
@@ -277,12 +301,18 @@ class CoreServiceProvider extends ServiceProvider
|
||||
// 플러그인 환경설정 로딩 (활성화된 플러그인만)
|
||||
$this->loadPluginSettingsToConfig($pluginManager);
|
||||
|
||||
// 확장 드라이버 Config 적용: 유효성 검증 + 폴백 + 훅 발행
|
||||
$this->applyExtensionDriverConfigs();
|
||||
|
||||
// 템플릿 로드 (콘솔 환경에서는 조건부 실행)
|
||||
if (! $skipTemplateLoading) {
|
||||
$templateManager = $this->app->make(TemplateManager::class);
|
||||
$templateManager->loadTemplates();
|
||||
$this->validateAndDeactivateIncompatibleTemplates($templateManager);
|
||||
}
|
||||
|
||||
// 동적 훅 리스너 일괄 실행 (registerDynamicHooks 메서드를 가진 리스너)
|
||||
$this->registerDeferredDynamicHooks();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,10 +360,30 @@ class CoreServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected function validateAndDeactivateIncompatibleExtensions($manager, string $type): void
|
||||
{
|
||||
// 코어 업데이트 진행 중에는 자동 비활성화 스킵.
|
||||
//
|
||||
// 업데이트는 다음 순서로 진행된다:
|
||||
// 1. 코어 파일 교체 (디스크)
|
||||
// 2. 업그레이드 스텝 실행 (spawn 프로세스)
|
||||
// 3. 번들 확장 일괄 업데이트 (spawn 내부, 파일 교체 + DB sync)
|
||||
// 4. .env APP_VERSION 갱신
|
||||
//
|
||||
// 3단계 동안 spawn 프로세스가 부팅될 때, 코어는 이미 신버전이지만 확장의 manifest 는
|
||||
// 아직 구버전이거나 그 반대. 버전 기반 호환성 판정을 수행하면 일시적 불일치로 전 확장이
|
||||
// 자동 비활성화되며, updateModule 이 `previousStatus` 를 잘못 캡처해 영구 비활성 상태로
|
||||
// 복원된다. 업데이트 중에는 판정 자체가 의미 없으므로 전면 skip 한다.
|
||||
//
|
||||
// `G7_UPDATE_IN_PROGRESS` 는 CoreUpdateCommand 가 시작 시 설정하고 spawn 의 `$env` 로
|
||||
// 전파된다. 업데이트가 종료되면 부모 프로세스 종료와 함께 env 도 소멸.
|
||||
if (self::isCoreUpdateInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cache = $this->app->make(CacheInterface::class);
|
||||
$cacheKey = CoreVersionChecker::getCacheKey($type);
|
||||
|
||||
// 캐시가 있으면 이미 검증된 것으로 간주
|
||||
if (Cache::has($cacheKey)) {
|
||||
if ($cache->has($cacheKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -365,7 +415,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
$this->storeDeactivatedExtensionsAlert($type, $deactivated);
|
||||
}
|
||||
|
||||
Cache::put($cacheKey, true, CoreVersionChecker::getCacheTtl());
|
||||
$cache->put($cacheKey, true, CoreVersionChecker::getCacheTtl());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,12 +426,41 @@ class CoreServiceProvider extends ServiceProvider
|
||||
*
|
||||
* @param TemplateManager $templateManager 템플릿 매니저
|
||||
*/
|
||||
/**
|
||||
* 현재 프로세스가 코어 업데이트 중인지 판정합니다.
|
||||
*
|
||||
* 판정 조건 (OR):
|
||||
* 1. 환경변수 `G7_UPDATE_IN_PROGRESS=1` — 부모 CoreUpdateCommand 가 시작 시 설정,
|
||||
* spawn 자식에도 `$env` 로 전파
|
||||
* 2. artisan command 이름이 `core:update` / `core:execute-upgrade-steps` — 1 이 전파되지
|
||||
* 않은 극단 상황 대비 보조 판정
|
||||
*
|
||||
* 둘 중 하나라도 true 면 업데이트 컨텍스트로 간주하여 version-based 자동 비활성화 스킵.
|
||||
*/
|
||||
public static function isCoreUpdateInProgress(): bool
|
||||
{
|
||||
$envFlag = $_ENV['G7_UPDATE_IN_PROGRESS'] ?? $_SERVER['G7_UPDATE_IN_PROGRESS'] ?? getenv('G7_UPDATE_IN_PROGRESS');
|
||||
if ($envFlag === '1' || $envFlag === 1 || $envFlag === true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$argv = $_SERVER['argv'] ?? [];
|
||||
$command = $argv[1] ?? '';
|
||||
return in_array($command, ['core:update', 'core:execute-upgrade-steps'], true);
|
||||
}
|
||||
|
||||
protected function validateAndDeactivateIncompatibleTemplates(TemplateManager $templateManager): void
|
||||
{
|
||||
// 업데이트 중 자동 비활성화 스킵 (validateAndDeactivateIncompatibleExtensions 와 동일 사유)
|
||||
if (self::isCoreUpdateInProgress()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cache = $this->app->make(CacheInterface::class);
|
||||
$cacheKey = CoreVersionChecker::getCacheKey('templates');
|
||||
|
||||
// 캐시가 있으면 이미 검증된 것으로 간주
|
||||
if (Cache::has($cacheKey)) {
|
||||
if ($cache->has($cacheKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -419,7 +498,7 @@ class CoreServiceProvider extends ServiceProvider
|
||||
$this->storeDeactivatedExtensionsAlert('templates', $deactivated);
|
||||
}
|
||||
|
||||
Cache::put($cacheKey, true, CoreVersionChecker::getCacheTtl());
|
||||
$cache->put($cacheKey, true, CoreVersionChecker::getCacheTtl());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -433,13 +512,14 @@ class CoreServiceProvider extends ServiceProvider
|
||||
*/
|
||||
protected function storeDeactivatedExtensionsAlert(string $type, array $deactivated): void
|
||||
{
|
||||
$alerts = Cache::get('extension_compatibility_alerts', []);
|
||||
$cache = $this->app->make(CacheInterface::class);
|
||||
$alerts = $cache->get('ext.compatibility_alerts', []);
|
||||
$alerts[$type] = [
|
||||
'deactivated' => $deactivated,
|
||||
'core_version' => config('app.version'),
|
||||
'timestamp' => now()->toIso8601String(),
|
||||
];
|
||||
Cache::put('extension_compatibility_alerts', $alerts, 86400); // 24시간
|
||||
$cache->put('ext.compatibility_alerts', $alerts, 86400); // 24시간
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -551,6 +631,69 @@ class CoreServiceProvider extends ServiceProvider
|
||||
Config::set('g7_settings.plugins', $pluginSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
* 확장 드라이버 Config을 적용합니다.
|
||||
*
|
||||
* 플러그인이 필터 훅으로 등록한 드라이버의 유효성을 검증하고,
|
||||
* 사용 가능하면 액션 훅을 발행하여 Config을 적용합니다.
|
||||
* 사용 불가능하면 기본 드라이버로 안전하게 폴백합니다.
|
||||
*
|
||||
* SettingsServiceProvider::register()에서 코어 드라이버 Config은 이미 적용된 상태이므로,
|
||||
* 여기서는 플러그인 드라이버만 처리합니다.
|
||||
*/
|
||||
protected function applyExtensionDriverConfigs(): void
|
||||
{
|
||||
try {
|
||||
$driverRegistry = $this->app->make(DriverRegistryService::class);
|
||||
$configRepository = $this->app->make(JsonConfigRepository::class);
|
||||
|
||||
foreach ($driverRegistry->getCategories() as $category) {
|
||||
$settingsKey = $driverRegistry->getSettingsKey($category);
|
||||
|
||||
if ($settingsKey === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$settings = $configRepository->getCategory($settingsKey['category']);
|
||||
$selectedDriver = $settings[$settingsKey['key']] ?? '';
|
||||
|
||||
if (empty($selectedDriver)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 코어 드라이버는 SettingsServiceProvider::register()에서 이미 적용됨
|
||||
if ($driverRegistry->isCoreDriver($category, $selectedDriver)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 플러그인 드라이버: 사용 가능 여부 확인
|
||||
if ($driverRegistry->isDriverAvailable($category, $selectedDriver)) {
|
||||
// 플러그인이 Config을 직접 적용하도록 액션 훅 발행
|
||||
HookManager::doAction(
|
||||
'core.settings.apply_driver_config',
|
||||
$category,
|
||||
$selectedDriver,
|
||||
$settings
|
||||
);
|
||||
} else {
|
||||
// 플러그인 드라이버가 사용 불가 → 기본 드라이버로 폴백
|
||||
$defaultDriver = $driverRegistry->getDefaultDriver($category);
|
||||
$configKey = $driverRegistry->getConfigKey($category);
|
||||
|
||||
if ($configKey && $defaultDriver) {
|
||||
Config::set($configKey, $defaultDriver);
|
||||
}
|
||||
|
||||
Log::warning("플러그인 드라이버 '{$selectedDriver}'가 '{$category}' 카테고리에서 사용 불가능합니다. 기본 드라이버 '{$defaultDriver}'로 폴백합니다.");
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('확장 드라이버 Config 적용 실패', [
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// registerActivityLogManager() 제거됨 — Monolog 채널(config/logging.php 'activity')로 대체
|
||||
|
||||
/**
|
||||
@@ -605,36 +748,11 @@ class CoreServiceProvider extends ServiceProvider
|
||||
private function registerCoreHookListener(string $listenerClass): void
|
||||
{
|
||||
try {
|
||||
// 구독할 훅 정보 가져오기
|
||||
$subscribedHooks = $listenerClass::getSubscribedHooks();
|
||||
HookListenerRegistrar::register($listenerClass, 'core');
|
||||
|
||||
foreach ($subscribedHooks as $hookName => $config) {
|
||||
$method = $config['method'] ?? 'handle';
|
||||
$priority = $config['priority'] ?? 10;
|
||||
$type = $config['type'] ?? 'action';
|
||||
|
||||
if ($type === 'filter') {
|
||||
// Filter 훅: 반환값을 전달 (클로저 래퍼로 지연 인스턴스 생성)
|
||||
HookManager::addFilter($hookName, function ($value, ...$args) use ($listenerClass, $method) {
|
||||
$listener = app($listenerClass);
|
||||
|
||||
return $listener->{$method}($value, ...$args);
|
||||
}, $priority);
|
||||
} else {
|
||||
// Action 훅 (클로저 래퍼로 지연 인스턴스 생성)
|
||||
HookManager::addAction($hookName, function (...$args) use ($listenerClass, $method) {
|
||||
$listener = app($listenerClass);
|
||||
$listener->{$method}(...$args);
|
||||
}, $priority);
|
||||
}
|
||||
|
||||
Log::info('코어 훅 리스너 등록 완료', [
|
||||
'hook' => $hookName,
|
||||
'listener' => $listenerClass,
|
||||
'method' => $method,
|
||||
'priority' => $priority,
|
||||
'type' => $type,
|
||||
]);
|
||||
// registerDynamicHooks() 메서드를 가진 리스너는 boot 후반부에서 실행
|
||||
if (method_exists($listenerClass, 'registerDynamicHooks')) {
|
||||
$this->deferredDynamicListeners[] = $listenerClass;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('코어 훅 리스너 등록 중 오류 발생', [
|
||||
@@ -645,13 +763,33 @@ class CoreServiceProvider extends ServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* registerDynamicHooks() 메서드를 가진 리스너들의 동적 훅을 일괄 등록합니다.
|
||||
*
|
||||
* DB 접근이 필요하므로 boot() 후반부(DB 유효성 검증 후)에서 호출됩니다.
|
||||
*/
|
||||
private function registerDeferredDynamicHooks(): void
|
||||
{
|
||||
foreach ($this->deferredDynamicListeners as $listenerClass) {
|
||||
try {
|
||||
$listener = app($listenerClass);
|
||||
$listener->registerDynamicHooks();
|
||||
|
||||
Log::info('동적 훅 리스너 등록 완료', ['listener' => $listenerClass]);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('동적 훅 리스너 등록 실패', [
|
||||
'listener' => $listenerClass,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 시스템 전역 라우트를 주입하는 필터를 등록합니다.
|
||||
*
|
||||
* core.routes.filter_merged 필터를 통해 프리뷰 등 코어 시스템 라우트를
|
||||
* 모든 템플릿의 routes.json 응답에 자동 주입합니다.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function registerSystemRouteFilters(): void
|
||||
{
|
||||
|
||||
@@ -49,19 +49,22 @@ class ModuleRouteServiceProvider extends ServiceProvider
|
||||
return;
|
||||
}
|
||||
|
||||
// DB 연결 가능 여부 및 테이블/컬럼 존재 여부 확인
|
||||
try {
|
||||
if (! Schema::hasTable('modules')) {
|
||||
return;
|
||||
}
|
||||
// 설치 완료 상태에서는 Schema introspection 을 건너뜀 (매 요청 쿼리 제거).
|
||||
// 인스톨러 이전 환경에서는 기존 체크 경로로 폴백.
|
||||
if (! config('app.installer_completed')) {
|
||||
try {
|
||||
if (! Schema::hasTable('modules')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// identifier 컬럼이 없으면 스킵 (마이그레이션 미적용 상태)
|
||||
if (! Schema::hasColumn('modules', 'identifier')) {
|
||||
// identifier 컬럼이 없으면 스킵 (마이그레이션 미적용 상태)
|
||||
if (! Schema::hasColumn('modules', 'identifier')) {
|
||||
return;
|
||||
}
|
||||
} catch (\Exception) {
|
||||
// DB 연결 실패 시 조용히 스킵 (설정 오류, 마이그레이션 전 등)
|
||||
return;
|
||||
}
|
||||
} catch (\Exception) {
|
||||
// DB 연결 실패 시 조용히 스킵 (설정 오류, 마이그레이션 전 등)
|
||||
return;
|
||||
}
|
||||
|
||||
// 활성화된 모듈 identifier 목록 가져오기
|
||||
|
||||
@@ -45,14 +45,17 @@ class PluginRouteServiceProvider extends ServiceProvider
|
||||
return;
|
||||
}
|
||||
|
||||
// DB 연결 가능 여부 및 테이블 존재 여부 확인
|
||||
try {
|
||||
if (! Schema::hasTable('plugins')) {
|
||||
// 설치 완료 상태에서는 Schema introspection 을 건너뜀 (매 요청 쿼리 제거).
|
||||
// 인스톨러 이전 환경에서는 기존 체크 경로로 폴백.
|
||||
if (! config('app.installer_completed')) {
|
||||
try {
|
||||
if (! Schema::hasTable('plugins')) {
|
||||
return;
|
||||
}
|
||||
} catch (\Exception) {
|
||||
// DB 연결 실패 시 조용히 스킵 (설정 오류, 마이그레이션 전 등)
|
||||
return;
|
||||
}
|
||||
} catch (\Exception) {
|
||||
// DB 연결 실패 시 조용히 스킵 (설정 오류, 마이그레이션 전 등)
|
||||
return;
|
||||
}
|
||||
|
||||
$plugins = File::directories($pluginsPath);
|
||||
|
||||
@@ -26,6 +26,7 @@ class SettingsServiceProvider extends ServiceProvider
|
||||
'cache',
|
||||
'upload',
|
||||
'core_update',
|
||||
'geoip',
|
||||
'seo',
|
||||
];
|
||||
|
||||
@@ -47,6 +48,7 @@ class SettingsServiceProvider extends ServiceProvider
|
||||
$this->applyCacheConfig($configRepository);
|
||||
$this->applyUploadConfig($configRepository);
|
||||
$this->applyCoreUpdateConfig($configRepository);
|
||||
$this->applyGeoIpConfig($configRepository);
|
||||
|
||||
// 코어 설정을 g7_settings.core prefix로 저장
|
||||
$this->loadCoreSettingsToConfig($configRepository);
|
||||
@@ -226,6 +228,13 @@ class SettingsServiceProvider extends ServiceProvider
|
||||
* 드라이버 설정을 Laravel config에 적용합니다.
|
||||
*
|
||||
* 캐시, 세션, 큐, 스토리지, Redis 드라이버 설정을 오버라이드합니다.
|
||||
*
|
||||
* **테스트 환경 격리**: `storage/app/settings/drivers.json`은 모든 환경이 공유하는
|
||||
* 파일이므로, testing 환경에서 cache/session/queue 드라이버를 덮어쓰면 phpunit.xml이
|
||||
* 지정한 테스트 전용 드라이버(array/array/sync)가 무시되고 dev의 Redis 등을 공유하게 됩니다.
|
||||
* 그 결과 테스트가 dev 캐시를 오염시켜 알림 훅 등록 같은 부팅 데이터가 silent하게
|
||||
* 망가지는 치명적 상태가 발생합니다. testing 환경에서는 드라이버 오버라이드를 건너뜁니다.
|
||||
* (이슈 #258)
|
||||
*/
|
||||
private function applyDriverConfig(JsonConfigRepository $configRepository): void
|
||||
{
|
||||
@@ -235,23 +244,28 @@ class SettingsServiceProvider extends ServiceProvider
|
||||
return;
|
||||
}
|
||||
|
||||
// testing 환경에서는 drivers.json의 cache/session/queue 오버라이드 차단 — 테스트 격리 보호
|
||||
// (storage/app/settings/drivers.json은 shared 파일이므로 dev의 Redis/DB 드라이버가
|
||||
// testing으로 흘러들어가면 dev 캐시를 오염시킴)
|
||||
$isTestingEnv = env('APP_ENV') === 'testing';
|
||||
|
||||
// 캐시 드라이버 설정
|
||||
if (! empty($driverSettings['cache_driver'])) {
|
||||
if (! $isTestingEnv && ! empty($driverSettings['cache_driver'])) {
|
||||
Config::set('cache.default', $driverSettings['cache_driver']);
|
||||
}
|
||||
|
||||
// 세션 드라이버 설정
|
||||
if (! empty($driverSettings['session_driver'])) {
|
||||
if (! $isTestingEnv && ! empty($driverSettings['session_driver'])) {
|
||||
Config::set('session.driver', $driverSettings['session_driver']);
|
||||
}
|
||||
|
||||
// 세션 수명 설정
|
||||
if (! empty($driverSettings['session_lifetime'])) {
|
||||
if (! $isTestingEnv && ! empty($driverSettings['session_lifetime'])) {
|
||||
Config::set('session.lifetime', (int) $driverSettings['session_lifetime']);
|
||||
}
|
||||
|
||||
// 큐 드라이버 설정
|
||||
if (! empty($driverSettings['queue_driver'])) {
|
||||
if (! $isTestingEnv && ! empty($driverSettings['queue_driver'])) {
|
||||
Config::set('queue.default', $driverSettings['queue_driver']);
|
||||
}
|
||||
|
||||
@@ -371,27 +385,90 @@ class SettingsServiceProvider extends ServiceProvider
|
||||
|
||||
/**
|
||||
* 웹소켓(Reverb) 설정을 적용합니다.
|
||||
*
|
||||
* 클라이언트(브라우저)와 서버(백엔드 broadcast HTTP API) endpoint를 분리합니다:
|
||||
* - 클라이언트: 외부에서 WebSocket으로 접속할 host/port (예: g7.dev:443)
|
||||
* → g7.websocket.client.* 에 저장 → admin.blade.php가 브라우저로 전달
|
||||
* - 서버: 백엔드 Pusher SDK가 broadcast HTTP API를 호출할 내부 endpoint (예: 127.0.0.1:8080)
|
||||
* → broadcasting.connections.reverb.options.* 에 저장 → Pusher SDK가 사용
|
||||
* → reverb.apps.apps.0.options.* 에 저장 → Reverb 서버 자체 설정
|
||||
*/
|
||||
private function applyWebsocketConfig(array $driverSettings): void
|
||||
{
|
||||
if (empty($driverSettings['websocket_enabled'])) {
|
||||
Config::set('broadcasting.default', 'null');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! empty($driverSettings['websocket_app_key'])) {
|
||||
Config::set('broadcasting.connections.reverb.key', $driverSettings['websocket_app_key']);
|
||||
$appId = $driverSettings['websocket_app_id'] ?? '';
|
||||
$appKey = $driverSettings['websocket_app_key'] ?? '';
|
||||
$appSecret = $driverSettings['websocket_app_secret'] ?? '';
|
||||
|
||||
// 클라이언트 endpoint (외부 — 브라우저 접속용)
|
||||
$clientHost = $driverSettings['websocket_host'] ?? '';
|
||||
$clientPort = (int) ($driverSettings['websocket_port'] ?? 0);
|
||||
$clientScheme = $driverSettings['websocket_scheme'] ?? '';
|
||||
$verifySsl = isset($driverSettings['websocket_verify_ssl']) ? (bool) $driverSettings['websocket_verify_ssl'] : null;
|
||||
|
||||
// 서버 endpoint (내부 — 백엔드 broadcast HTTP API용)
|
||||
// server 키가 비어있으면 클라이언트 값으로 fallback (단일 호스트 환경 호환)
|
||||
$serverHost = $driverSettings['websocket_server_host'] ?? '';
|
||||
$serverPort = (int) ($driverSettings['websocket_server_port'] ?? 0);
|
||||
$serverScheme = $driverSettings['websocket_server_scheme'] ?? '';
|
||||
if (empty($serverHost)) {
|
||||
$serverHost = $clientHost;
|
||||
}
|
||||
if ($serverPort <= 0) {
|
||||
$serverPort = $clientPort;
|
||||
}
|
||||
if (empty($serverScheme)) {
|
||||
$serverScheme = $clientScheme;
|
||||
}
|
||||
$serverUseTLS = $serverScheme === 'https';
|
||||
|
||||
// 공통: 앱 자격증명
|
||||
if (! empty($appKey)) {
|
||||
Config::set('broadcasting.connections.reverb.key', $appKey);
|
||||
Config::set('reverb.apps.apps.0.key', $appKey);
|
||||
}
|
||||
if (! empty($appSecret)) {
|
||||
Config::set('broadcasting.connections.reverb.secret', $appSecret);
|
||||
Config::set('reverb.apps.apps.0.secret', $appSecret);
|
||||
}
|
||||
if (! empty($appId)) {
|
||||
Config::set('broadcasting.connections.reverb.app_id', $appId);
|
||||
Config::set('reverb.apps.apps.0.app_id', $appId);
|
||||
}
|
||||
|
||||
if (! empty($driverSettings['websocket_host'])) {
|
||||
Config::set('broadcasting.connections.reverb.options.host', $driverSettings['websocket_host']);
|
||||
// 백엔드 broadcast HTTP API용 endpoint (Pusher SDK가 사용)
|
||||
if (! empty($serverHost)) {
|
||||
Config::set('broadcasting.connections.reverb.options.host', $serverHost);
|
||||
Config::set('reverb.apps.apps.0.options.host', $serverHost);
|
||||
}
|
||||
if ($serverPort > 0) {
|
||||
Config::set('broadcasting.connections.reverb.options.port', $serverPort);
|
||||
Config::set('reverb.apps.apps.0.options.port', $serverPort);
|
||||
}
|
||||
if (! empty($serverScheme)) {
|
||||
Config::set('broadcasting.connections.reverb.options.scheme', $serverScheme);
|
||||
Config::set('broadcasting.connections.reverb.options.useTLS', $serverUseTLS);
|
||||
Config::set('reverb.apps.apps.0.options.scheme', $serverScheme);
|
||||
Config::set('reverb.apps.apps.0.options.useTLS', $serverUseTLS);
|
||||
}
|
||||
if ($verifySsl !== null) {
|
||||
Config::set('broadcasting.connections.reverb.client_options.verify', $verifySsl);
|
||||
}
|
||||
|
||||
if (! empty($driverSettings['websocket_port'])) {
|
||||
Config::set('broadcasting.connections.reverb.options.port', (int) $driverSettings['websocket_port']);
|
||||
// 클라이언트(브라우저) 접속용 endpoint — Blade에서 읽어 G7Core에 전달
|
||||
if (! empty($clientHost)) {
|
||||
Config::set('g7.websocket.client.host', $clientHost);
|
||||
}
|
||||
|
||||
if (! empty($driverSettings['websocket_scheme'])) {
|
||||
Config::set('broadcasting.connections.reverb.options.scheme', $driverSettings['websocket_scheme']);
|
||||
if ($clientPort > 0) {
|
||||
Config::set('g7.websocket.client.port', $clientPort);
|
||||
}
|
||||
if (! empty($clientScheme)) {
|
||||
Config::set('g7.websocket.client.scheme', $clientScheme);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,6 +495,40 @@ class SettingsServiceProvider extends ServiceProvider
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GeoIP 설정을 Laravel config에 적용합니다.
|
||||
*
|
||||
* cache.json의 geoip_* 값으로 config('geoip.*')을 오버라이드합니다.
|
||||
* 마스터 스위치(geoip.feature_enabled)가 곧 config('geoip.enabled')의
|
||||
* 런타임 값이 됩니다. env('GEOIP_ENABLED')는 fallback 역할.
|
||||
*
|
||||
* @param JsonConfigRepository $configRepository 설정 저장소
|
||||
*/
|
||||
private function applyGeoIpConfig(JsonConfigRepository $configRepository): void
|
||||
{
|
||||
$settings = $configRepository->getCategory('geoip');
|
||||
|
||||
if (empty($settings)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($settings['feature_enabled'])) {
|
||||
Config::set('geoip.enabled', (bool) $settings['feature_enabled']);
|
||||
}
|
||||
|
||||
if (! empty($settings['license_key'])) {
|
||||
Config::set('geoip.license_key', $settings['license_key']);
|
||||
}
|
||||
|
||||
if (isset($settings['auto_update_enabled'])) {
|
||||
Config::set('geoip.auto_update_enabled', (bool) $settings['auto_update_enabled']);
|
||||
}
|
||||
|
||||
if (! empty($settings['last_updated_at'])) {
|
||||
Config::set('geoip.last_updated_at', $settings['last_updated_at']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 캐시 설정을 Laravel config에 적용합니다.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user