v7.0.0-beta.1 release
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ActivateModuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'module_name' => 'required|string|max:255',
|
||||
'force' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.activate_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'module_name.required' => __('modules.validation.name_required'),
|
||||
'module_name.string' => __('modules.validation.name_string'),
|
||||
'module_name.max' => __('modules.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class DeactivateModuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'module_name' => 'required|string|max:255',
|
||||
'force' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.deactivate_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'module_name.required' => __('modules.validation.name_required'),
|
||||
'module_name.string' => __('modules.validation.name_string'),
|
||||
'module_name.max' => __('modules.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 모듈 목록 조회 요청
|
||||
*
|
||||
* 다중 검색 조건을 지원합니다.
|
||||
* - search: 단일 검색어 (이름, 식별자, 설명, 벤더 OR 검색) - 하위 호환성
|
||||
* - filters: 다중 검색 조건 (AND 조건)
|
||||
* - with[]: 추가 데이터 포함 (예: custom_menus)
|
||||
*/
|
||||
class IndexModuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 검색 가능한 필드 목록
|
||||
*/
|
||||
public const SEARCHABLE_FIELDS = ['name', 'identifier', 'description', 'vendor'];
|
||||
|
||||
/**
|
||||
* with 파라미터로 요청 가능한 추가 데이터 목록
|
||||
*/
|
||||
public const ALLOWED_WITH_OPTIONS = ['custom_menus'];
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$searchableFields = implode(',', self::SEARCHABLE_FIELDS);
|
||||
$allowedWithOptions = implode(',', self::ALLOWED_WITH_OPTIONS);
|
||||
|
||||
$rules = [
|
||||
// 단일 검색어 (하위 호환성 - 이름, 식별자, 설명, 벤더 OR 검색)
|
||||
'search' => 'nullable|string|max:255',
|
||||
|
||||
// 다중 검색 조건
|
||||
'filters' => 'nullable|array|max:10',
|
||||
'filters.*.field' => "required_with:filters|string|in:{$searchableFields}",
|
||||
'filters.*.value' => 'required_with:filters|string|max:255',
|
||||
'filters.*.operator' => 'nullable|string|in:like,eq,starts_with,ends_with',
|
||||
|
||||
// 상태 필터
|
||||
'status' => 'nullable|string|in:installed,not_installed,active,inactive',
|
||||
|
||||
// 추가 데이터 포함
|
||||
'with' => 'nullable|array|max:5',
|
||||
'with.*' => "string|in:{$allowedWithOptions}",
|
||||
|
||||
// 페이지네이션
|
||||
'per_page' => 'nullable|integer|min:1|max:100',
|
||||
'page' => 'nullable|integer|min:1',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.index_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'search.max' => __('modules.validation.search_max'),
|
||||
'filters.max' => __('modules.validation.filters_max'),
|
||||
'filters.*.field.required_with' => __('modules.validation.filter_field_required'),
|
||||
'filters.*.field.in' => __('modules.validation.filter_field_invalid'),
|
||||
'filters.*.value.required_with' => __('modules.validation.filter_value_required'),
|
||||
'filters.*.value.max' => __('modules.validation.filter_value_max'),
|
||||
'filters.*.operator.in' => __('modules.validation.filter_operator_invalid'),
|
||||
'status.in' => __('modules.validation.status_invalid'),
|
||||
'with.max' => __('modules.validation.with_max'),
|
||||
'with.*.in' => __('modules.validation.with_invalid'),
|
||||
'per_page.min' => __('modules.validation.per_page_min'),
|
||||
'per_page.max' => __('modules.validation.per_page_max'),
|
||||
'page.min' => __('modules.validation.page_min'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* with 파라미터에 특정 옵션이 포함되어 있는지 확인합니다.
|
||||
*
|
||||
* @param string $option 확인할 옵션명
|
||||
* @return bool 포함 여부
|
||||
*/
|
||||
public function hasWithOption(string $option): bool
|
||||
{
|
||||
$withOptions = $this->validated('with', []);
|
||||
|
||||
return in_array($option, $withOptions, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* 파일에서 모듈 설치 요청
|
||||
*/
|
||||
class InstallModuleFromFileRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$maxSize = config('module.upload_max_size', 50) * 1024; // MB를 KB로 변환
|
||||
|
||||
$rules = [
|
||||
'file' => [
|
||||
'required',
|
||||
'file',
|
||||
'mimes:zip',
|
||||
'max:' . $maxSize,
|
||||
],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.install_from_file_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
$maxSize = config('module.upload_max_size', 50);
|
||||
|
||||
return [
|
||||
'file.required' => __('modules.validation.file_required'),
|
||||
'file.file' => __('modules.validation.file_invalid'),
|
||||
'file.mimes' => __('modules.validation.file_must_be_zip'),
|
||||
'file.max' => __('modules.validation.file_max_size', ['size' => $maxSize]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
/**
|
||||
* GitHub에서 모듈 설치 요청
|
||||
*/
|
||||
class InstallModuleFromGithubRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'github_url' => [
|
||||
'required',
|
||||
'url',
|
||||
'regex:/^https?:\/\/(www\.)?github\.com\/[a-zA-Z0-9\-_]+\/[a-zA-Z0-9\-_]+\/?$/',
|
||||
],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.install_from_github_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'github_url.required' => __('modules.validation.github_url_required'),
|
||||
'github_url.url' => __('modules.validation.github_url_invalid'),
|
||||
'github_url.regex' => __('modules.validation.github_url_format'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Rules\ValidExtensionIdentifier;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class InstallModuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'module_name' => ['required', 'string', 'max:255', new ValidExtensionIdentifier],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.install_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'module_name.required' => __('modules.validation.name_required'),
|
||||
'module_name.string' => __('modules.validation.name_string'),
|
||||
'module_name.max' => __('modules.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RefreshModuleLayoutsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'module_name' => 'required|string|max:255',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.refresh_layouts_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'module_name.required' => __('modules.validation.name_required'),
|
||||
'module_name.string' => __('modules.validation.name_string'),
|
||||
'module_name.max' => __('modules.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UninstallModuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'module_name' => 'required|string|max:255',
|
||||
'delete_data' => 'sometimes|boolean',
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.uninstall_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom messages for validator errors.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'module_name.required' => __('modules.validation.name_required'),
|
||||
'module_name.string' => __('modules.validation.name_string'),
|
||||
'module_name.max' => __('modules.validation.name_max'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Module;
|
||||
|
||||
use App\Enums\ExtensionStatus;
|
||||
use App\Extension\HookManager;
|
||||
use App\Rules\TranslatableField;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
/**
|
||||
* 모듈 업데이트 요청 검증
|
||||
*
|
||||
* 모듈의 name, description, status를 업데이트할 수 있습니다.
|
||||
* name과 description은 다국어 필드로 처리됩니다.
|
||||
*/
|
||||
class UpdateModuleRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* 사용자가 이 요청을 수행할 권한이 있는지 확인
|
||||
*
|
||||
* 권한 체크는 라우트의 permission 미들웨어에서 수행됩니다.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 데이터 전처리
|
||||
*
|
||||
* 역호환성을 위해 문자열로 들어온 name, description을
|
||||
* 다국어 배열 형식으로 자동 변환합니다.
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$locales = config('app.translatable_locales', ['ko', 'en']);
|
||||
|
||||
// name이 문자열로 들어온 경우 배열로 변환 (역호환성)
|
||||
if ($this->has('name') && is_string($this->name)) {
|
||||
$nameArray = [];
|
||||
foreach ($locales as $locale) {
|
||||
$nameArray[$locale] = $this->name;
|
||||
}
|
||||
$this->merge(['name' => $nameArray]);
|
||||
}
|
||||
|
||||
// description이 문자열로 들어온 경우 배열로 변환
|
||||
if ($this->has('description') && is_string($this->description)) {
|
||||
$descriptionArray = [];
|
||||
foreach ($locales as $locale) {
|
||||
$descriptionArray[$locale] = $this->description;
|
||||
}
|
||||
$this->merge(['description' => $descriptionArray]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => ['nullable', new TranslatableField(maxLength: 255)],
|
||||
'description' => ['nullable', new TranslatableField(maxLength: 1000)],
|
||||
'status' => ['nullable', 'string', Rule::in(ExtensionStatus::values())],
|
||||
];
|
||||
|
||||
// 모듈/플러그인이 validation rules를 동적으로 추가할 수 있도록 훅 제공
|
||||
return HookManager::applyFilters('core.module.update_validation_rules', $rules, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 오류 메시지 커스터마이징
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'status.in' => __('validation.module.status.in'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user