v7.0.0-beta.1 release

This commit is contained in:
HeuJung committed 2026-04-01 10:30:52 +09:00
commit 6595fd0eb5
3967 files changed
+1875383

No files matched your search

@@ -0,0 +1,74 @@
<?php
namespace App\Notifications\Auth;
use App\Enums\ExtensionOwnerType;
use App\Mail\DbTemplateMail;
use App\Notifications\BaseNotification;
use App\Services\MailTemplateService;
/**
* 비밀번호 변경 완료 알림
*
* 비밀번호가 변경되었음을 사용자에게 알립니다.
* 훅을 통해 SMS, 카카오톡 등 다른 채널로 확장 가능합니다.
*/
class PasswordChangedNotification extends BaseNotification
{
/**
* {@inheritdoc}
*/
protected function getHookPrefix(): string
{
return 'core.auth';
}
/**
* {@inheritdoc}
*/
protected function getNotificationType(): string
{
return 'password_changed';
}
/**
* 이메일 알림을 생성합니다.
*
* @param object $notifiable 수신자
* @return DbTemplateMail DB 템플릿 기반 이메일 (비활성 시 스킵 인스턴스)
*/
public function toMail(object $notifiable): DbTemplateMail
{
$service = app(MailTemplateService::class);
$template = $service->resolveTemplate('password_changed');
if (! $template) {
return DbTemplateMail::skipped(
recipientEmail: $notifiable->email,
templateType: 'password_changed',
extensionType: ExtensionOwnerType::Core,
extensionIdentifier: 'core',
recipientName: $notifiable->name ?? null,
);
}
$variables = [
'name' => $notifiable->name ?? '',
'app_name' => config('app.name'),
'action_url' => config('app.url') . '/login',
'site_url' => config('app.url'),
];
$rendered = $service->renderTemplate($template, $variables);
return new DbTemplateMail(
renderedSubject: $rendered['subject'],
renderedBody: $rendered['body'],
recipientEmail: $notifiable->email,
templateType: 'password_changed',
extensionType: ExtensionOwnerType::Core,
extensionIdentifier: 'core',
recipientName: $notifiable->name ?? null,
);
}
}
@@ -0,0 +1,105 @@
<?php
namespace App\Notifications\Auth;
use App\Enums\ExtensionOwnerType;
use App\Mail\DbTemplateMail;
use App\Notifications\BaseNotification;
use App\Services\MailTemplateService;
/**
* 비밀번호 재설정 알림
*
* 비밀번호 재설정 링크를 사용자에게 발송합니다.
* 훅을 통해 SMS, 카카오톡 등 다른 채널로 확장 가능합니다.
*/
class ResetPasswordNotification extends BaseNotification
{
/**
* 비밀번호 재설정 알림을 생성합니다.
*
* @param string $token 비밀번호 재설정 토큰
* @param string|null $redirectPrefix 리다이렉트 경로 접두사 (예: 'admin')
*/
public function __construct(
private string $token,
private ?string $redirectPrefix = null
) {}
/**
* {@inheritdoc}
*/
protected function getHookPrefix(): string
{
return 'core.auth';
}
/**
* {@inheritdoc}
*/
protected function getNotificationType(): string
{
return 'reset_password';
}
/**
* 이메일 알림을 생성합니다.
*
* @param object $notifiable 수신자
* @return DbTemplateMail DB 템플릿 기반 이메일 (비활성 시 스킵 인스턴스)
*/
public function toMail(object $notifiable): DbTemplateMail
{
$service = app(MailTemplateService::class);
$template = $service->resolveTemplate('reset_password');
if (! $template) {
return DbTemplateMail::skipped(
recipientEmail: $notifiable->email,
templateType: 'reset_password',
extensionType: ExtensionOwnerType::Core,
extensionIdentifier: 'core',
recipientName: $notifiable->name ?? null,
);
}
$resetPath = $this->redirectPrefix
? '/' . $this->redirectPrefix . '/reset-password'
: '/reset-password';
$url = config('app.url') . $resetPath . '?' . http_build_query([
'token' => $this->token,
'email' => $notifiable->email,
]);
$expireMinutes = config('auth.passwords.users.expire', 60);
$variables = [
'name' => $notifiable->name ?? '',
'app_name' => config('app.name'),
'action_url' => $url,
'expire_minutes' => (string) $expireMinutes,
'site_url' => config('app.url'),
];
$rendered = $service->renderTemplate($template, $variables);
return new DbTemplateMail(
renderedSubject: $rendered['subject'],
renderedBody: $rendered['body'],
recipientEmail: $notifiable->email,
templateType: 'reset_password',
extensionType: ExtensionOwnerType::Core,
extensionIdentifier: 'core',
recipientName: $notifiable->name ?? null,
);
}
/**
* 비밀번호 재설정 토큰을 반환합니다.
*
* @return string
*/
public function getToken(): string
{
return $this->token;
}
}
@@ -0,0 +1,74 @@
<?php
namespace App\Notifications\Auth;
use App\Enums\ExtensionOwnerType;
use App\Mail\DbTemplateMail;
use App\Notifications\BaseNotification;
use App\Services\MailTemplateService;
/**
* 회원가입 완료 알림
*
* 회원가입이 완료되었음을 사용자에게 알립니다.
* 훅을 통해 SMS, 카카오톡 등 다른 채널로 확장 가능합니다.
*/
class WelcomeNotification extends BaseNotification
{
/**
* {@inheritdoc}
*/
protected function getHookPrefix(): string
{
return 'core.auth';
}
/**
* {@inheritdoc}
*/
protected function getNotificationType(): string
{
return 'welcome';
}
/**
* 이메일 알림을 생성합니다.
*
* @param object $notifiable 수신자
* @return DbTemplateMail DB 템플릿 기반 이메일 (비활성 시 스킵 인스턴스)
*/
public function toMail(object $notifiable): DbTemplateMail
{
$service = app(MailTemplateService::class);
$template = $service->resolveTemplate('welcome');
if (! $template) {
return DbTemplateMail::skipped(
recipientEmail: $notifiable->email,
templateType: 'welcome',
extensionType: ExtensionOwnerType::Core,
extensionIdentifier: 'core',
recipientName: $notifiable->name ?? null,
);
}
$variables = [
'name' => $notifiable->name ?? '',
'app_name' => config('app.name'),
'action_url' => config('app.url') . '/login',
'site_url' => config('app.url'),
];
$rendered = $service->renderTemplate($template, $variables);
return new DbTemplateMail(
renderedSubject: $rendered['subject'],
renderedBody: $rendered['body'],
recipientEmail: $notifiable->email,
templateType: 'welcome',
extensionType: ExtensionOwnerType::Core,
extensionIdentifier: 'core',
recipientName: $notifiable->name ?? null,
);
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace App\Notifications;
use App\Extension\HookManager;
use Illuminate\Notifications\Notification;
/**
* 알림 기본 추상 클래스
*
* 모든 그누보드7 알림의 공통 기반입니다.
* via() 메서드에서 HookManager를 통해 채널 목록을 동적으로 결정합니다.
* 플러그인은 Filter 훅으로 채널을 추가/제거할 수 있습니다.
*
* toMail()은 정의하지 않습니다 — 각 서브클래스가 직접 구현합니다 (Laravel 규약).
*/
abstract class BaseNotification extends Notification
{
/**
* 훅 접두사를 반환합니다.
*
* 예: 'core.auth', 'sirsoft-board', 'sirsoft-ecommerce'
*
* @return string 훅 접두사
*/
abstract protected function getHookPrefix(): string;
/**
* 알림 유형을 반환합니다.
*
* 예: 'welcome', 'reset_password', 'new_comment'
*
* @return string 알림 유형
*/
abstract protected function getNotificationType(): string;
/**
* 알림 채널을 결정합니다.
*
* Filter 훅으로 플러그인이 채널을 추가/제거할 수 있습니다.
* 훅명: {hookPrefix}.notification.channels
*
* @param object $notifiable 수신자
* @return array<string> 채널 목록
*/
public function via(object $notifiable): array
{
return HookManager::applyFilters(
"{$this->getHookPrefix()}.notification.channels",
['mail'],
$this->getNotificationType(),
$notifiable
);
}
}