v7.0.0-beta.4 release

This commit is contained in:
HeuJung committed 2026-05-11 11:29:41 +09:00
1 parent 05db17887d
commit 1db039ff34
1545 files changed
+136783 -11634

No files matched your search

@@ -0,0 +1,34 @@
<?php
namespace App\Exceptions\Auth;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* 계정 잠금 예외 — 보안 환경설정의 `max_login_attempts` 도달 후
* `login_lockout_time` 분 동안 로그인 시도를 차단할 때 발생합니다.
*
* HTTP 423 Locked 응답으로 매핑되며, 프론트엔드 토스트는 다국어 키
* `auth.account_locked` 로 잔여 분(`minutes` 플레이스홀더)을 노출합니다.
*
* 컨트롤러는 본 예외를 별도로 catch 하여 ResponseHelper 응답을 만들거나,
* 글로벌 예외 핸들러가 자동으로 423 JSON 응답으로 변환합니다.
*
* @since 7.0.0
*/
class AccountLockedException extends HttpException
{
public function __construct(
public readonly Carbon $lockedUntil,
public readonly int $remainingMinutes,
?string $message = null,
) {
parent::__construct(
423,
$message ?? 'auth.account_locked',
null,
['Retry-After' => max(1, $remainingMinutes * 60)]
);
}
}
@@ -1,22 +0,0 @@
<?php
namespace App\Exceptions;
use Exception;
/**
* 관리자 계정 삭제 시도 시 발생하는 예외
*
* 관리자 역할을 가진 계정은 시스템에서 삭제할 수 없으며,
* 이 예외는 삭제 시도를 방지합니다.
*/
class CannotDeleteAdminException extends Exception
{
/**
* 관리자 계정 삭제 시도 시 예외를 생성합니다.
*/
public function __construct()
{
parent::__construct(__('user.delete_admin_forbidden'));
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Exceptions;
use RuntimeException;
use Throwable;
/**
* 코어 업데이트 흐름에서 발생하는 운영 오류 예외.
*
* 다국어 키 + 파라미터를 보존하여 컨트롤러/리스너가 원본 키를 활용 가능. 코어
* 업데이트의 다운로드/검증/추출/composer 실행/소유권 복원 등 단계에서 회복 불가
* 한 실패가 발생할 때 사용한다.
*/
class CoreUpdateOperationException extends RuntimeException
{
/**
* @param string $errorKey 다국어 키 (예: 'settings.core_update.zip_file_not_found')
* @param array<string, mixed> $params 메시지 파라미터
* @param Throwable|null $previous 원인 예외
*/
public function __construct(
public readonly string $errorKey,
public readonly array $params = [],
?Throwable $previous = null,
) {
parent::__construct(__($errorKey, $params), 0, $previous);
}
}
@@ -0,0 +1,64 @@
<?php
namespace App\Exceptions;
/**
* 확장 코어 버전 호환성 검사 실패.
*
* `update*`/`activate*`/원클릭 복구 등 확장 매니저가 코어 버전 호환성 사전 검증에서
* 실패할 때 던집니다. 글로벌 Handler 가 HTTP 422 + `error_code: 'core_version_mismatch'`
* 응답으로 매핑하여 프론트가 일관된 toast/배너/모달 안내를 표시할 수 있게 합니다.
*
* **부모 클래스 선택**: 의도적으로 `\Error` 를 상속한다 (IDV 예외와 동일 패턴).
*
* 이유: 코어/모듈/플러그인 컨트롤러 다수가 `try { ... } catch (\Exception $e) { ... }`
* catch-all 로 자체 응답 변환을 수행한다. 본 예외가 `\Exception` 자식이면 그 catch-all
* 에 포획되어 generic 422 로 강등 → `error_code` 와 구조화 payload 가 모두 사라져
* 프론트가 일관된 안내(toast/배너/모달)를 표시할 수 없다. `\Error` 는 PHP 의 `\Exception`
* 과 별도 계층이므로 catch-all 을 통과하여 글로벌 render() 콜백으로 도달한다.
*
* 명시 catch 가 필요한 호출자는 `catch (CoreVersionMismatchException $e)` 또는
* `catch (\Throwable $e)` 로 잡을 수 있다.
*
* @since 7.0.0-beta.4
*/
class CoreVersionMismatchException extends \Error
{
/**
* @param string $extensionType 확장 타입 (module|plugin|template)
* @param string $identifier 확장 식별자
* @param string $requiredCoreVersion 요구된 코어 버전 제약
* @param string $currentCoreVersion 현재 설치된 코어 버전
* @param string $message 사람이 읽을 수 있는 메시지 (이미 번역된 문자열)
*/
public function __construct(
public readonly string $extensionType,
public readonly string $identifier,
public readonly string $requiredCoreVersion,
public readonly string $currentCoreVersion,
string $message = '',
) {
parent::__construct($message ?: __('extensions.errors.core_version_mismatch', [
'extension' => $identifier,
'type' => __('extensions.types.'.$extensionType),
'required' => $requiredCoreVersion,
'installed' => $currentCoreVersion,
]));
}
/**
* 응답 payload 빌더.
*
* @return array{extension_type: string, identifier: string, required_core_version: string, current_core_version: string, guide_url: string}
*/
public function getPayload(): array
{
return [
'extension_type' => $this->extensionType,
'identifier' => $this->identifier,
'required_core_version' => $this->requiredCoreVersion,
'current_core_version' => $this->currentCoreVersion,
'guide_url' => '/admin/core/update',
];
}
}
@@ -0,0 +1,59 @@
<?php
namespace App\Exceptions;
/**
* 정책 위반 — 본인인증 필요.
*
* 미들웨어/Listener 가 정책 매칭 후 던지며, 글로벌 Handler 가 HTTP 428 (Precondition Required) 응답으로 매핑합니다.
* 프론트 `ErrorHandlingResolver` 가 이 상태코드 + error_code 를 감지해 자동으로 Challenge 모달을 열고
* return_request 를 재실행합니다.
*
* **부모 클래스 선택 (CRITICAL)**: 의도적으로 `\Error` 를 상속한다.
*
* 이유: 코어/모듈/플러그인 컨트롤러 23+ 곳이 `try { ... } catch (\Exception $e) { ... }` 패턴으로
* 자체 응답 변환을 하는데, IDV 예외가 `\Exception` 자식이면 그 catch-all 에 포획되어 422 일반
* 에러로 강등 → 프론트 IdentityGuardInterceptor 가 모달을 띄우지 못한다.
* `\Error` 는 PHP 의 `\Exception` 과 별도 계층이므로 `catch (\Exception)` 으로 잡히지 않으며,
* Laravel 글로벌 핸들러의 `render(Throwable)` 콜백은 `\Throwable` 으로 받아 정상 428 매핑한다.
*
* 즉 어떤 라우트 (코어/모듈/플러그인) 에서 어느 catch-all 패턴이 있어도 IDV 흐름은 항상 글로벌
* 핸들러까지 도달한다 — 라우트별 안전망 코드 작성 불필요.
*
* 예외적으로 명시 catch 가 필요한 호출자는 `catch (IdentityVerificationRequiredException $e)`
* 또는 `catch (\Throwable $e)` 로 잡을 수 있다 (테스트의 expectException 도 정상 작동).
*
* @since 7.0.0-beta.4
*/
class IdentityVerificationRequiredException extends \Error
{
/**
* @param string $policyKey 매칭된 정책 식별자 (identity_policies.key)
* @param string $purpose 요구되는 IDV purpose
* @param string|null $providerId 특정 provider 강제 시 id, null 이면 기본
* @param string|null $renderHint 프론트 렌더 힌트
* @param array|null $returnRequest 재실행할 원 요청 정보 (method/url/headers_echo)
*/
public function __construct(
public readonly string $policyKey,
public readonly string $purpose,
public readonly ?string $providerId = null,
public readonly ?string $renderHint = null,
public readonly ?array $returnRequest = null,
string $message = 'identity.errors.verification_required',
) {
parent::__construct($message);
}
public function getPayload(): array
{
return [
'policy_key' => $this->policyKey,
'purpose' => $this->purpose,
'provider_id' => $this->providerId,
'render_hint' => $this->renderHint,
'challenge_start_url' => '/api/identity/challenges',
'return_request' => $this->returnRequest,
];
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Exceptions;
use RuntimeException;
use Throwable;
/**
* 언어팩 설치/활성화/업데이트/검증 흐름에서 발생하는 운영 오류 예외.
*
* 다국어 키 + 파라미터를 보존하여 컨트롤러/리스너가 원본 키를 활용 가능합니다.
* `LanguagePackSlotConflictException` 와 같이 의미가 분리된 예외는 별도 클래스로 유지하고,
* 본 클래스는 일반 운영 흐름의 단일 메시지 throw 캡슐화에 사용합니다.
*/
class LanguagePackOperationException extends RuntimeException
{
/**
* @param string $errorKey 다국어 키 (예: 'language_packs.errors.download_failed')
* @param array<string, mixed> $params 메시지 파라미터
* @param Throwable|null $previous 원인 예외
*/
public function __construct(
public readonly string $errorKey,
public readonly array $params = [],
?Throwable $previous = null,
) {
parent::__construct(__($errorKey, $params), 0, $previous);
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Exceptions;
use App\Models\LanguagePack;
use RuntimeException;
/**
* 같은 슬롯(scope + target_identifier + locale)에 이미 활성 언어팩이 있을 때
* `force=false` 로 활성화를 시도하면 발생합니다. 컨트롤러는 이 예외를 잡아
* 409 응답으로 변환하고, 프론트엔드는 사용자에게 교체 확인 모달을 띄웁니다.
*/
class LanguagePackSlotConflictException extends RuntimeException
{
public function __construct(
public readonly LanguagePack $current,
public readonly LanguagePack $target,
) {
parent::__construct(__('language_packs.errors.slot_conflict', [
'current' => $current->identifier,
'target' => $target->identifier,
]));
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Exceptions;
use RuntimeException;
use Throwable;
/**
* 모듈 설치/활성화/업데이트 흐름에서 발생하는 운영 오류 예외.
*
* 다국어 키 + 파라미터를 보존하여 컨트롤러/리스너가 원본 키를 활용 가능합니다.
*/
class ModuleOperationException extends RuntimeException
{
/**
* @param string $errorKey 다국어 키 (예: 'modules.errors.install_failed')
* @param array<string, mixed> $params 메시지 파라미터
* @param Throwable|null $previous 원인 예외
*/
public function __construct(
public readonly string $errorKey,
public readonly array $params = [],
?Throwable $previous = null,
) {
parent::__construct(__($errorKey, $params), 0, $previous);
}
}
@@ -0,0 +1,27 @@
<?php
namespace App\Exceptions;
use RuntimeException;
use Throwable;
/**
* 플러그인 설치/활성화/업데이트 흐름에서 발생하는 운영 오류 예외.
*
* 다국어 키 + 파라미터를 보존하여 컨트롤러/리스너가 원본 키를 활용 가능합니다.
*/
class PluginOperationException extends RuntimeException
{
/**
* @param string $errorKey 다국어 키 (예: 'plugins.errors.install_failed')
* @param array<string, mixed> $params 메시지 파라미터
* @param Throwable|null $previous 원인 예외
*/
public function __construct(
public readonly string $errorKey,
public readonly array $params = [],
?Throwable $previous = null,
) {
parent::__construct(__($errorKey, $params), 0, $previous);
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Exceptions;
use RuntimeException;
use Throwable;
/**
* 템플릿 설치/업데이트 흐름에서 발생하는 운영 오류 예외.
*
* 다국어 키 + 파라미터를 보존하여 컨트롤러/리스너가 원본 키를 활용 가능합니다.
* `TemplateNotFoundException` / `TemplateFileCopyException` 등 의미가 분리된 예외는
* 별도 클래스로 유지하고, 본 클래스는 일반 운영 흐름의 단일 메시지 throw 캡슐화에 사용합니다.
*/
class TemplateOperationException extends RuntimeException
{
/**
* @param string $errorKey 다국어 키 (예: 'templates.errors.install_failed')
* @param array<string, mixed> $params 메시지 파라미터
* @param Throwable|null $previous 원인 예외
*/
public function __construct(
public readonly string $errorKey,
public readonly array $params = [],
?Throwable $previous = null,
) {
parent::__construct(__($errorKey, $params), 0, $previous);
}
}