v7.0.0-beta.4 release
This commit is contained in:
1 parent
05db17887d
commit
1db039ff34
1545 files changed
+136783
-11634
No files matched your search
+302
-95
@@ -2,8 +2,14 @@
|
||||
|
||||
namespace App\Seo;
|
||||
|
||||
use App\Seo\Concerns\LocalizesSeoValues;
|
||||
use App\Seo\Concerns\SubstitutesSeoVariables;
|
||||
|
||||
class SeoMetaResolver
|
||||
{
|
||||
use LocalizesSeoValues;
|
||||
use SubstitutesSeoVariables;
|
||||
|
||||
public function __construct(
|
||||
private readonly ExpressionEvaluator $evaluator,
|
||||
) {}
|
||||
@@ -51,19 +57,28 @@ class SeoMetaResolver
|
||||
$title = $title ?? '';
|
||||
$description = $description ?? '';
|
||||
|
||||
// OG 태그 해석
|
||||
$ogTags = $this->resolveOgTags($seoConfig, $context, $title, $description);
|
||||
|
||||
// 구조화 데이터 (JSON-LD) 해석
|
||||
$jsonLd = $this->resolveStructuredData($seoConfig, $context);
|
||||
// OG / Twitter / Structured Data 배열 해석 (HTML 렌더 지연)
|
||||
$og = $this->resolveOgData($seoConfig, $context, $title, $description);
|
||||
$twitter = $this->resolveTwitterData($seoConfig, $context, $og);
|
||||
$structuredData = $this->resolveStructuredDataArray($seoConfig, $context);
|
||||
|
||||
return [
|
||||
'title' => $title,
|
||||
'titleSuffix' => $titleSuffix,
|
||||
'description' => $description,
|
||||
'keywords' => $keywords,
|
||||
'ogTags' => $ogTags,
|
||||
'jsonLd' => $jsonLd,
|
||||
|
||||
// 신설: 배열 형태 (확장이 hook 으로 수정 가능)
|
||||
'og' => $og,
|
||||
'twitter' => $twitter,
|
||||
'structured_data' => $structuredData,
|
||||
'extraMetaTags' => [],
|
||||
|
||||
// 후방 호환: HTML/JSON 문자열도 함께 채움 (filter_meta 후 SeoRenderer 가 재계산)
|
||||
'ogTags' => $this->renderOgHtml($og),
|
||||
'twitterTags' => $this->renderTwitterHtml($twitter),
|
||||
'jsonLd' => $this->renderStructuredJson($structuredData),
|
||||
|
||||
'googleAnalyticsId' => g7_core_settings('seo.google_analytics_id', ''),
|
||||
'googleVerification' => g7_core_settings('seo.google_site_verification', ''),
|
||||
'naverVerification' => g7_core_settings('seo.naver_site_verification', ''),
|
||||
@@ -182,6 +197,12 @@ class SeoMetaResolver
|
||||
$keywords = data_get($dsData, 'data.meta_keywords');
|
||||
if (! empty($keywords)) {
|
||||
if (is_array($keywords)) {
|
||||
// 다국어 JSON ({"ko": "...", "en": "..."}) 분기 — locale 추출
|
||||
if ($this->isLocalizedArray($keywords)) {
|
||||
return $this->resolveLocalizedValue($keywords);
|
||||
}
|
||||
|
||||
// 키워드 list 인 경우 (정수 키 배열)
|
||||
return implode(',', $keywords);
|
||||
}
|
||||
|
||||
@@ -210,7 +231,7 @@ class SeoMetaResolver
|
||||
foreach ($context as $dsData) {
|
||||
$value = data_get($dsData, "data.{$field}");
|
||||
if ($value !== null && $value !== '') {
|
||||
return (string) $value;
|
||||
return $this->resolveLocalizedValue($value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +250,7 @@ class SeoMetaResolver
|
||||
foreach ($context as $dsData) {
|
||||
$value = data_get($dsData, "data.seo_meta.{$field}");
|
||||
if ($value !== null && $value !== '') {
|
||||
return (string) $value;
|
||||
return $this->resolveLocalizedValue($value);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
@@ -346,11 +367,12 @@ class SeoMetaResolver
|
||||
private function resolveVarExpression(string $expr, array $context, ?string $moduleIdentifier, ?string $pluginIdentifier = null): string
|
||||
{
|
||||
// $module_settings:key 또는 $module_settings:module-id:key
|
||||
// 다국어 JSON 배열 설정값도 안전 처리 (resolveLocalizedValue)
|
||||
if (str_starts_with($expr, '$module_settings:')) {
|
||||
$rest = substr($expr, strlen('$module_settings:'));
|
||||
[$effectiveId, $key] = $this->parseExtensionSettingsKey($rest, $moduleIdentifier);
|
||||
if ($effectiveId) {
|
||||
return (string) g7_module_settings($effectiveId, $key, '');
|
||||
return $this->resolveLocalizedValue(g7_module_settings($effectiveId, $key, ''));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,7 +381,7 @@ class SeoMetaResolver
|
||||
$rest = substr($expr, strlen('$plugin_settings:'));
|
||||
[$effectiveId, $key] = $this->parseExtensionSettingsKey($rest, $pluginIdentifier);
|
||||
if ($effectiveId) {
|
||||
return (string) g7_plugin_settings($effectiveId, $key, '');
|
||||
return $this->resolveLocalizedValue(g7_plugin_settings($effectiveId, $key, ''));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,14 +389,14 @@ class SeoMetaResolver
|
||||
if (str_starts_with($expr, '$core_settings:')) {
|
||||
$key = substr($expr, strlen('$core_settings:'));
|
||||
|
||||
return (string) g7_core_settings($key, '');
|
||||
return $this->resolveLocalizedValue(g7_core_settings($key, ''));
|
||||
}
|
||||
|
||||
// $query:key
|
||||
if (str_starts_with($expr, '$query:')) {
|
||||
$key = substr($expr, strlen('$query:'));
|
||||
|
||||
return (string) request()->query($key, '');
|
||||
return $this->resolveLocalizedValue(request()->query($key, ''));
|
||||
}
|
||||
|
||||
// {{expression}} → ExpressionEvaluator
|
||||
@@ -406,23 +428,6 @@ class SeoMetaResolver
|
||||
return [$contextIdentifier, $rest];
|
||||
}
|
||||
|
||||
/**
|
||||
* 해석된 변수로 템플릿 문자열을 치환합니다.
|
||||
*
|
||||
* @param string $template 템플릿 문자열 ({var_name} 플레이스홀더 포함)
|
||||
* @param array $resolvedVars 해석된 변수 (키 → 값)
|
||||
* @return string 치환된 문자열
|
||||
*/
|
||||
private function substituteVars(string $template, array $resolvedVars): string
|
||||
{
|
||||
$replacements = [];
|
||||
foreach ($resolvedVars as $key => $value) {
|
||||
$replacements['{'.$key.'}'] = $value;
|
||||
}
|
||||
|
||||
return str_replace(array_keys($replacements), array_values($replacements), $template);
|
||||
}
|
||||
|
||||
/**
|
||||
* 레이아웃 meta의 title을 해석합니다 (fallback용).
|
||||
*
|
||||
@@ -432,10 +437,10 @@ class SeoMetaResolver
|
||||
*/
|
||||
private function resolveLayoutMetaTitle(array $seoConfig, array $context): string
|
||||
{
|
||||
// meta.seo.og.title이 있으면 사용
|
||||
// meta.seo.og.title이 있으면 사용. 다국어 array literal 도 허용 (safeEval).
|
||||
$ogTitle = data_get($seoConfig, 'og.title', '');
|
||||
if ($ogTitle !== '') {
|
||||
return $this->evaluator->evaluate($ogTitle, $context);
|
||||
if ($ogTitle !== '' && $ogTitle !== null && $ogTitle !== []) {
|
||||
return $this->safeEval($ogTitle, $context);
|
||||
}
|
||||
|
||||
return '';
|
||||
@@ -450,77 +455,305 @@ class SeoMetaResolver
|
||||
*/
|
||||
private function resolveLayoutMetaDescription(array $seoConfig, array $context): string
|
||||
{
|
||||
// 다국어 array literal 도 허용 (safeEval).
|
||||
$ogDescription = data_get($seoConfig, 'og.description', '');
|
||||
if ($ogDescription !== '') {
|
||||
return $this->stripHtml($this->evaluator->evaluate($ogDescription, $context));
|
||||
if ($ogDescription !== '' && $ogDescription !== null && $ogDescription !== []) {
|
||||
return $this->stripHtml($this->safeEval($ogDescription, $context));
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* OG 태그를 생성합니다.
|
||||
* OG 메타태그를 배열 형태로 해석합니다 (HTML 렌더 지연).
|
||||
*
|
||||
* 레이아웃 meta.seo.og 선언 + 코어 설정 fallback 으로 og 데이터를 구성.
|
||||
* SeoRenderer 가 모듈 declaration 과 deep-merge 한 뒤 hook 적용 가능하도록 배열 반환.
|
||||
*
|
||||
* @param array $seoConfig SEO 설정
|
||||
* @param array $context 데이터 컨텍스트
|
||||
* @param string $fallbackTitle fallback 타이틀
|
||||
* @param string $fallbackDescription fallback 설명
|
||||
* @return string OG 메타태그 HTML
|
||||
* @return array OG 데이터 배열 (type, title, description, image, image_*, site_name, locale, extra)
|
||||
*/
|
||||
private function resolveOgTags(array $seoConfig, array $context, string $fallbackTitle, string $fallbackDescription): string
|
||||
public function resolveOgData(array $seoConfig, array $context, string $fallbackTitle, string $fallbackDescription): array
|
||||
{
|
||||
$og = $seoConfig['og'] ?? [];
|
||||
if (empty($og)) {
|
||||
return '';
|
||||
|
||||
$title = $this->stripHtml($this->safeEval($og['title'] ?? '', $context)) ?: $fallbackTitle;
|
||||
$description = $this->stripHtml($this->safeEval($og['description'] ?? '', $context)) ?: $fallbackDescription;
|
||||
$image = $this->absoluteUrl($this->safeEval($og['image'] ?? '', $context));
|
||||
$secureUrl = isset($og['image_secure_url'])
|
||||
? $this->absoluteUrl($this->safeEval($og['image_secure_url'], $context))
|
||||
: ($image !== '' && str_starts_with($image, 'https://') ? $image : '');
|
||||
|
||||
// site_name fallback: 코어 설정이 다국어 array 일 수 있으므로 resolveLocalizedValue 통과
|
||||
$explicitSiteName = $this->stripHtml($this->safeEval($og['site_name'] ?? '', $context));
|
||||
$siteNameFallback = g7_core_settings('seo.og_default_site_name');
|
||||
if ($siteNameFallback === null || $siteNameFallback === '') {
|
||||
$siteNameFallback = g7_core_settings('general.site_name', '');
|
||||
}
|
||||
|
||||
$tags = '';
|
||||
$ogType = $this->evaluator->evaluate($og['type'] ?? 'website', $context);
|
||||
$ogTitle = $this->stripHtml($this->evaluator->evaluate($og['title'] ?? '', $context)) ?: $fallbackTitle;
|
||||
$ogDescription = $this->stripHtml($this->evaluator->evaluate($og['description'] ?? '', $context)) ?: $fallbackDescription;
|
||||
$ogImage = $this->evaluator->evaluate($og['image'] ?? '', $context);
|
||||
|
||||
$tags .= '<meta property="og:type" content="'.e($ogType).'">'."\n";
|
||||
|
||||
if ($ogTitle !== '') {
|
||||
$tags .= ' <meta property="og:title" content="'.e($ogTitle).'">'."\n";
|
||||
}
|
||||
|
||||
if ($ogDescription !== '') {
|
||||
$tags .= ' <meta property="og:description" content="'.e($ogDescription).'">'."\n";
|
||||
}
|
||||
|
||||
if ($ogImage !== '') {
|
||||
$absoluteImage = str_starts_with($ogImage, 'http') ? $ogImage : url($ogImage);
|
||||
$tags .= ' <meta property="og:image" content="'.e($absoluteImage).'">'."\n";
|
||||
}
|
||||
|
||||
return $tags;
|
||||
return [
|
||||
'type' => $this->safeEval($og['type'] ?? 'website', $context),
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'image' => $image,
|
||||
'image_secure_url' => $secureUrl,
|
||||
'image_width' => $this->resolveIntOrSetting($og['image_width'] ?? null, 'seo.og_image_default_width', $context),
|
||||
'image_height' => $this->resolveIntOrSetting($og['image_height'] ?? null, 'seo.og_image_default_height', $context),
|
||||
'image_type' => $this->safeEval($og['image_type'] ?? '', $context),
|
||||
'image_alt' => $this->stripHtml($this->safeEval($og['image_alt'] ?? $og['title'] ?? '', $context)),
|
||||
'site_name' => $explicitSiteName !== '' ? $explicitSiteName : $this->resolveLocalizedValue($siteNameFallback),
|
||||
'locale' => $this->safeEval($og['locale'] ?? '', $context) ?: app()->getLocale(),
|
||||
'extra' => is_array($og['extra'] ?? null) ? $og['extra'] : [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 구조화 데이터 (JSON-LD)를 생성합니다.
|
||||
* Twitter 카드 메타태그를 배열 형태로 해석합니다.
|
||||
*
|
||||
* 미선언 필드는 OG 데이터를 fallback 으로 사용 (Slack 등이 트위터 카드를 폴백 경로로 활용).
|
||||
*
|
||||
* @param array $seoConfig SEO 설정
|
||||
* @param array $context 데이터 컨텍스트
|
||||
* @return string|null JSON-LD 문자열 또는 null
|
||||
* @param array $ogData resolveOgData 결과 (fallback 용)
|
||||
* @return array Twitter 카드 데이터
|
||||
*/
|
||||
private function resolveStructuredData(array $seoConfig, array $context): ?string
|
||||
public function resolveTwitterData(array $seoConfig, array $context, array $ogData): array
|
||||
{
|
||||
$tw = $seoConfig['twitter'] ?? [];
|
||||
$hasImage = ($ogData['image'] ?? '') !== '';
|
||||
|
||||
// 코어 설정이 다국어 array 일 가능성 대비 — resolveLocalizedValue 통과
|
||||
$cardFallback = g7_core_settings('seo.twitter_default_card', $hasImage ? 'summary_large_image' : 'summary');
|
||||
$siteFallback = g7_core_settings('seo.twitter_default_site', '');
|
||||
|
||||
return [
|
||||
'card' => isset($tw['card']) ? $this->safeEval((string) $tw['card'], $context) : $this->resolveLocalizedValue($cardFallback),
|
||||
'site' => isset($tw['site']) ? $this->safeEval((string) $tw['site'], $context) : $this->resolveLocalizedValue($siteFallback),
|
||||
'creator' => $this->safeEval($tw['creator'] ?? '', $context),
|
||||
'title' => isset($tw['title'])
|
||||
? $this->stripHtml($this->safeEval($tw['title'], $context))
|
||||
: (string) ($ogData['title'] ?? ''),
|
||||
'description' => isset($tw['description'])
|
||||
? $this->stripHtml($this->safeEval($tw['description'], $context))
|
||||
: (string) ($ogData['description'] ?? ''),
|
||||
'image' => isset($tw['image'])
|
||||
? $this->absoluteUrl($this->safeEval($tw['image'], $context))
|
||||
: (string) ($ogData['image'] ?? ''),
|
||||
'image_alt' => isset($tw['image_alt'])
|
||||
? $this->stripHtml($this->safeEval($tw['image_alt'], $context))
|
||||
: (string) ($ogData['image_alt'] ?? ''),
|
||||
'extra' => is_array($tw['extra'] ?? null) ? $tw['extra'] : [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 구조화 데이터 (JSON-LD)를 배열 형태로 해석합니다.
|
||||
*
|
||||
* 표현식 평가만 수행하고 JSON 직렬화는 renderStructuredJson 에서.
|
||||
*
|
||||
* @param array $seoConfig SEO 설정
|
||||
* @param array $context 데이터 컨텍스트
|
||||
* @return array|null 평가된 스키마 배열 또는 null
|
||||
*/
|
||||
public function resolveStructuredDataArray(array $seoConfig, array $context): ?array
|
||||
{
|
||||
$structuredData = $seoConfig['structured_data'] ?? null;
|
||||
if (empty($structuredData)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 구조화 데이터 내 표현식 재귀 평가
|
||||
$resolved = $this->resolveStructuredDataRecursive($structuredData, $context);
|
||||
return $this->resolveStructuredDataRecursive($structuredData, $context);
|
||||
}
|
||||
|
||||
// @context 추가
|
||||
$resolved = array_merge(['@context' => 'https://schema.org'], $resolved);
|
||||
/**
|
||||
* OG 데이터 배열을 HTML 메타태그로 렌더합니다.
|
||||
*
|
||||
* @param array $og OG 데이터 배열
|
||||
* @return string HTML 메타태그
|
||||
*/
|
||||
public function renderOgHtml(array $og): string
|
||||
{
|
||||
$tags = '';
|
||||
$type = (string) ($og['type'] ?? '');
|
||||
if ($type === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tags .= '<meta property="og:type" content="'.e($type).'">'."\n";
|
||||
|
||||
$title = (string) ($og['title'] ?? '');
|
||||
if ($title !== '') {
|
||||
$tags .= ' <meta property="og:title" content="'.e($title).'">'."\n";
|
||||
}
|
||||
$description = (string) ($og['description'] ?? '');
|
||||
if ($description !== '') {
|
||||
$tags .= ' <meta property="og:description" content="'.e($description).'">'."\n";
|
||||
}
|
||||
|
||||
$image = (string) ($og['image'] ?? '');
|
||||
if ($image !== '') {
|
||||
$tags .= ' <meta property="og:image" content="'.e($image).'">'."\n";
|
||||
|
||||
$secure = (string) ($og['image_secure_url'] ?? '');
|
||||
if ($secure !== '' && str_starts_with($secure, 'https://')) {
|
||||
$tags .= ' <meta property="og:image:secure_url" content="'.e($secure).'">'."\n";
|
||||
}
|
||||
$imageType = (string) ($og['image_type'] ?? '');
|
||||
if ($imageType !== '') {
|
||||
$tags .= ' <meta property="og:image:type" content="'.e($imageType).'">'."\n";
|
||||
}
|
||||
$width = $og['image_width'] ?? null;
|
||||
if (is_numeric($width) && (int) $width > 0) {
|
||||
$tags .= ' <meta property="og:image:width" content="'.(int) $width.'">'."\n";
|
||||
}
|
||||
$height = $og['image_height'] ?? null;
|
||||
if (is_numeric($height) && (int) $height > 0) {
|
||||
$tags .= ' <meta property="og:image:height" content="'.(int) $height.'">'."\n";
|
||||
}
|
||||
$imageAlt = (string) ($og['image_alt'] ?? '');
|
||||
if ($imageAlt !== '') {
|
||||
$tags .= ' <meta property="og:image:alt" content="'.e($imageAlt).'">'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
$siteName = (string) ($og['site_name'] ?? '');
|
||||
if ($siteName !== '') {
|
||||
$tags .= ' <meta property="og:site_name" content="'.e($siteName).'">'."\n";
|
||||
}
|
||||
|
||||
foreach ((array) ($og['extra'] ?? []) as $entry) {
|
||||
if (! is_array($entry)) {
|
||||
continue;
|
||||
}
|
||||
$prop = (string) ($entry['property'] ?? '');
|
||||
$content = (string) ($entry['content'] ?? '');
|
||||
if ($prop !== '' && $content !== '') {
|
||||
$tags .= ' <meta property="'.e($prop).'" content="'.e($content).'">'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Twitter 데이터 배열을 HTML 메타태그로 렌더합니다.
|
||||
*
|
||||
* @param array $tw Twitter 데이터 배열
|
||||
* @return string HTML 메타태그
|
||||
*/
|
||||
public function renderTwitterHtml(array $tw): string
|
||||
{
|
||||
$card = (string) ($tw['card'] ?? '');
|
||||
if ($card === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tags = '<meta name="twitter:card" content="'.e($card).'">'."\n";
|
||||
|
||||
foreach (['site', 'creator', 'title', 'description', 'image'] as $key) {
|
||||
$val = (string) ($tw[$key] ?? '');
|
||||
if ($val !== '') {
|
||||
$tags .= ' <meta name="twitter:'.$key.'" content="'.e($val).'">'."\n";
|
||||
}
|
||||
}
|
||||
$imageAlt = (string) ($tw['image_alt'] ?? '');
|
||||
if ($imageAlt !== '') {
|
||||
$tags .= ' <meta name="twitter:image:alt" content="'.e($imageAlt).'">'."\n";
|
||||
}
|
||||
foreach ((array) ($tw['extra'] ?? []) as $entry) {
|
||||
if (! is_array($entry)) {
|
||||
continue;
|
||||
}
|
||||
$name = (string) ($entry['name'] ?? '');
|
||||
$content = (string) ($entry['content'] ?? '');
|
||||
if ($name !== '' && $content !== '') {
|
||||
$tags .= ' <meta name="'.e($name).'" content="'.e($content).'">'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* 구조화 데이터 배열을 JSON-LD 문자열로 렌더합니다.
|
||||
*
|
||||
* @param array|null $structuredData 구조화 데이터 배열
|
||||
* @return string|null JSON-LD 문자열 또는 null
|
||||
*/
|
||||
public function renderStructuredJson(?array $structuredData): ?string
|
||||
{
|
||||
if (empty($structuredData)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$resolved = array_merge(['@context' => 'https://schema.org'], $structuredData);
|
||||
|
||||
return json_encode($resolved, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 표현식을 평가하여 항상 string 으로 반환.
|
||||
*
|
||||
* - string + {{...}} 표현식 → ExpressionEvaluator 로 평가 (string 보장)
|
||||
* - 다국어 array (`["ko" => "...", "en" => "..."]`) → 현재 로케일 → fallback locale 순으로 추출
|
||||
* - 그 외 (numeric, bool, null, 기타 array) → resolveLocalizedValue 로 string 변환
|
||||
*
|
||||
* 'Array to string conversion' / TypeError 회귀 방지 — resolveOgData/resolveTwitterData 에서
|
||||
* 모든 표현식 평가 지점은 본 헬퍼를 거쳐야 함.
|
||||
*/
|
||||
private function safeEval(mixed $expr, array $context): string
|
||||
{
|
||||
if (is_string($expr)) {
|
||||
return $this->evaluator->evaluate($expr, $context);
|
||||
}
|
||||
|
||||
return $this->resolveLocalizedValue($expr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 상대 경로 URL 을 절대 URL 로 변환.
|
||||
*/
|
||||
private function absoluteUrl(string $url): string
|
||||
{
|
||||
if ($url === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
return str_starts_with($url, 'http') ? $url : url($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 정수 값 해석 — 명시값 우선, 없으면 코어 설정 fallback.
|
||||
*
|
||||
* @param mixed $value 레이아웃 선언 값 (int|string expr|null)
|
||||
* @param string $settingKey 코어 설정 키
|
||||
* @param array $context 데이터 컨텍스트 (표현식 평가용)
|
||||
* @return int|null 정수 또는 null
|
||||
*/
|
||||
private function resolveIntOrSetting(mixed $value, string $settingKey, array $context): ?int
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
$default = g7_core_settings($settingKey);
|
||||
|
||||
return is_numeric($default) ? (int) $default : null;
|
||||
}
|
||||
|
||||
if (is_int($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
$evaluated = $this->evaluator->evaluate($value, $context);
|
||||
|
||||
return is_numeric($evaluated) ? (int) $evaluated : null;
|
||||
}
|
||||
|
||||
return is_numeric($value) ? (int) $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 구조화 데이터를 재귀적으로 표현식 평가합니다.
|
||||
*
|
||||
@@ -582,32 +815,6 @@ class SeoMetaResolver
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 다국어 객체에서 현재 로케일 값을 추출합니다.
|
||||
*
|
||||
* @param mixed $value 다국어 객체 또는 문자열
|
||||
* @return string 현재 로케일 값
|
||||
*/
|
||||
private function resolveLocalizedValue(mixed $value): string
|
||||
{
|
||||
if (is_string($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
$locale = app()->getLocale();
|
||||
if (isset($value[$locale])) {
|
||||
return (string) $value[$locale];
|
||||
}
|
||||
$fallbackLocale = config('app.fallback_locale', 'en');
|
||||
if (isset($value[$fallbackLocale])) {
|
||||
return (string) $value[$fallbackLocale];
|
||||
}
|
||||
}
|
||||
|
||||
return (string) ($value ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML 태그를 제거하고 공백을 정규화합니다.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user