Files
Gnuboard7/app/Helpers/settings_helpers.php
HeuJung 4e1ec6e001 fix(core,admin_basic,board,ecommerce,page,gdpr,verification): 설정 미러·자동 정리·탈퇴 원자성·일괄 선택 범위 정비
공개이슈 ··· 및 그 전수 해소분.

- 설정 저장·복원·초기화가 상주 프로세스 미러를 갱신하도록 단일 소유자화
- 만료 데이터 자동 정리 예약 12종 신설, 파기는 기본키 배치로 분할
- 회원 탈퇴를 전 경로 원자화하고 관리자 상태변경 경로를 정식 탈퇴로 통일
- 일괄 처리 목록의 선택을 화면에 보이는 행으로 한정(selectionScope)
- 비밀번호 정책 문구를 도메인 중립 라벨로 정정
- 정적 검사 2종·검증 스킬 설계 정합성 축 신설
2026-08-14 11:06:25 +09:00

161 lines
5.6 KiB
PHP

<?php
use App\Support\ExtensionSettingsMirror;
use Illuminate\Support\Facades\Config;
if (! function_exists('g7_settings')) {
/**
* 그누보드7 통합 환경설정 조회 헬퍼 함수
*
* 코어, 모듈, 플러그인의 환경설정을 통합하여 조회합니다.
* 부트스트랩 시점에 로드된 설정값을 Config에서 읽어옵니다.
*
* @param string|null $key 설정 키 (dot notation)
* @param mixed $default 기본값
* @return mixed 설정값 또는 전체 설정 배열
*
* @example
* // 코어 메일 설정 조회
* $mailHost = g7_settings('core.mail.host');
* @example
* // 모듈 설정 조회
* $shopName = g7_settings('modules.sirsoft-ecommerce.basic_info.shop_name');
* @example
* // 플러그인 설정 조회
* $displayMode = g7_settings('plugins.sirsoft-daum_postcode.display_mode');
* @example
* // 전체 설정 조회
* $allSettings = g7_settings();
*/
function g7_settings(?string $key = null, mixed $default = null): mixed
{
if ($key === null) {
return Config::get('g7_settings', []);
}
return Config::get("g7_settings.{$key}", $default);
}
}
if (! function_exists('g7_core_settings')) {
/**
* 그누보드7 코어 환경설정 조회 헬퍼 함수
*
* @param string|null $key 설정 키 (dot notation)
* @param mixed $default 기본값
* @return mixed 설정값
*
* @example
* // 메일 호스트 조회
* $mailHost = g7_core_settings('mail.host');
* @example
* // 사이트명 조회
* $siteName = g7_core_settings('general.site_name');
*/
function g7_core_settings(?string $key = null, mixed $default = null): mixed
{
if ($key === null) {
return Config::get('g7_settings.core', []);
}
return Config::get("g7_settings.core.{$key}", $default);
}
}
if (! function_exists('g7_module_settings')) {
/**
* 그누보드7 모듈 환경설정 조회 헬퍼 함수
*
* @param string $identifier 모듈 식별자 (예: 'sirsoft-ecommerce')
* @param string|null $key 설정 키 (dot notation)
* @param mixed $default 기본값
* @return mixed 설정값
*
* @example
* // 이커머스 모듈의 쇼핑몰명 조회
* $shopName = g7_module_settings('sirsoft-ecommerce', 'basic_info.shop_name');
* @example
* // 모듈 전체 설정 조회
* $allSettings = g7_module_settings('sirsoft-ecommerce');
*/
function g7_module_settings(string $identifier, ?string $key = null, mixed $default = null): mixed
{
if ($key === null) {
return Config::get("g7_settings.modules.{$identifier}", []);
}
return Config::get("g7_settings.modules.{$identifier}.{$key}", $default);
}
}
if (! function_exists('g7_refresh_module_settings_config')) {
/**
* 모듈 환경설정 config 미러를 다시 채웁니다.
*
* 모듈 설정 저장에는 코어 공통 지점이 없어 각 모듈의 SettingsService 가 직접 저장합니다.
* 그 서비스가 자기 캐시를 비우는 자리에서 이 헬퍼를 호출하면, 상주 프로세스에서도
* `g7_module_settings()` 가 저장 직후의 값을 읽습니다 (공개이슈 #109).
*
* @param string $identifier 모듈 식별자 (예: sirsoft-ecommerce)
* @return void
*/
function g7_refresh_module_settings_config(string $identifier): void
{
app(ExtensionSettingsMirror::class)->refreshModule($identifier);
}
}
if (! function_exists('g7_plugin_settings')) {
/**
* 그누보드7 플러그인 환경설정 조회 헬퍼 함수
*
* @param string $identifier 플러그인 식별자 (예: 'sirsoft-daum_postcode')
* @param string|null $key 설정 키 (dot notation)
* @param mixed $default 기본값
* @return mixed 설정값
*
* @example
* // 다음 우편번호 플러그인의 표시 모드 조회
* $displayMode = g7_plugin_settings('sirsoft-daum_postcode', 'display_mode');
* @example
* // 플러그인 전체 설정 조회
* $allSettings = g7_plugin_settings('sirsoft-daum_postcode');
*/
function g7_plugin_settings(string $identifier, ?string $key = null, mixed $default = null): mixed
{
if ($key === null) {
return Config::get("g7_settings.plugins.{$identifier}", []);
}
return Config::get("g7_settings.plugins.{$identifier}.{$key}", $default);
}
}
if (! function_exists('g7_meta_generator_tag')) {
/**
* `<meta name="generator">` 태그 HTML을 생성합니다.
*
* 코어 SEO 설정(`seo.generator_enabled`, `seo.generator_content`)에 따라
* 메타 태그를 출력합니다. SEO 봇 페이지·SPA 셸·Admin 셸에서 공통 호출됩니다.
*
* - `seo.generator_enabled` 가 false 이면 빈 문자열 반환
* - `seo.generator_content` 가 빈 값이면 `"GnuBoard7 {버전}"` 자동 적용
* - content 는 e() 로 escape 처리되어 XSS 방어됨
*
* @return string `<meta name="generator" content="...">` 또는 빈 문자열
*/
function g7_meta_generator_tag(): string
{
if (! g7_core_settings('seo.generator_enabled', true)) {
return '';
}
$content = trim((string) g7_core_settings('seo.generator_content', ''));
if ($content === '') {
$content = trim('GnuBoard7 '.config('app.version', ''));
}
return '<meta name="generator" content="'.e($content).'">';
}
}