feat(core,ecommerce,ckeditor5): 이미지 업로드 필터 훅 대칭화
공개 제보(리뷰 이미지에 filter_upload_file 부재)를 계기로 전 이미지 업로드 경로의 훅 트라이어드를 대칭화한다. 확장이 업로드 파일을 저장 전에 가로채 압축/변환할 수 있도록 하기 위함. - 리뷰 이미지·CKEditor5 이미지 업로드에 filter_upload_file 필터 훅 추가 - 레이아웃 편집기 첨부 업로드에 훅 트라이어드(before/filter/after) 신설 - ckeditor5 1.0.2 버전 동기(manifest/package/composer/lock), 각 CHANGELOG 기재, README 기여자 등재, hooks.md 업로드 트라이어드 및 필터 반환 계약 문서화 - 시나리오 매니페스트(upload-filter-hook-parity) + 3계층 훅 발화 테스트 추가
This commit is contained in:
1 parent
709fbff278
commit
b1b5bfa417
18 files changed
+1279
-6
No files matched your search
@@ -4,6 +4,12 @@
|
||||
형식은 [Keep a Changelog](https://keepachangelog.com/ko/1.1.0/)를 따르며,
|
||||
[Semantic Versioning](https://semver.org/lang/ko/)을 준수합니다.
|
||||
|
||||
## [1.0.2] - 2026-08-12
|
||||
|
||||
### Added
|
||||
|
||||
- 에디터 이미지 업로드에 파일 가공 필터 훅 제공 — 확장에서 업로드 이미지를 저장 전에 변환할 수 있습니다.
|
||||
|
||||
## [1.0.1] - 2026-08-10
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "plugins/sirsoft-ckeditor5",
|
||||
"description": "CKEditor 5 WYSIWYG Editor Plugin for Gnuboard7 platform",
|
||||
"type": "library",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"authors": [
|
||||
{
|
||||
"name": "sirsoft",
|
||||
|
||||
+1023
-3
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@g7/sirsoft-ckeditor5",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "그누보드7 CKEditor 5 WYSIWYG 에디터 플러그인 프론트엔드 에셋",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"ko": "CKEditor 5 WYSIWYG 에디터",
|
||||
"en": "CKEditor 5 WYSIWYG Editor"
|
||||
},
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"license": "MIT",
|
||||
"description": {
|
||||
"ko": "CKEditor 5를 이용한 WYSIWYG 에디터 플러그인입니다. 플러그인 설치만으로 기존 HtmlEditor가 교체됩니다.",
|
||||
|
||||
@@ -38,6 +38,9 @@ class ImageUploadService
|
||||
// 훅: 이미지 업로드 전 (본인인증 등 확장 지점)
|
||||
HookManager::doAction('sirsoft-ckeditor5.image.before_upload', $file, $uploadedBy);
|
||||
|
||||
// 필터 훅 - 파일 데이터 변형 (압축, 리사이즈 등 확장 포인트)
|
||||
$file = HookManager::applyFilters('sirsoft-ckeditor5.image.filter_upload_file', $file);
|
||||
|
||||
$extension = $file->guessExtension() ?? $file->getClientOriginalExtension();
|
||||
$storedFilename = Str::uuid().'.'.$extension;
|
||||
$path = date('Y/m/d').'/'.$storedFilename;
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Plugins\Sirsoft\Ckeditor5\Tests\Unit\Services;
|
||||
|
||||
use App\Contracts\Extension\StorageInterface;
|
||||
use App\Extension\HookManager;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Plugins\Sirsoft\Ckeditor5\Models\Ckeditor5ImageUpload;
|
||||
use Plugins\Sirsoft\Ckeditor5\Repositories\Contracts\ImageUploadRepositoryInterface;
|
||||
use Plugins\Sirsoft\Ckeditor5\Services\ImageUploadService;
|
||||
use Plugins\Sirsoft\Ckeditor5\Tests\PluginTestCase;
|
||||
|
||||
/**
|
||||
* ImageUploadService 단위 테스트
|
||||
*
|
||||
* 업로드 훅 트라이어드(before_upload → filter_upload_file → after_upload) 발화를 검증합니다.
|
||||
* upload 자체 동작(저장/기록)은 Feature ImageUploadControllerTest 가 커버합니다.
|
||||
*/
|
||||
class ImageUploadServiceTest extends PluginTestCase
|
||||
{
|
||||
private ImageUploadService $service;
|
||||
|
||||
/** @var MockInterface&ImageUploadRepositoryInterface */
|
||||
private $repository;
|
||||
|
||||
/** @var MockInterface&StorageInterface */
|
||||
private $storage;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->repository = Mockery::mock(ImageUploadRepositoryInterface::class);
|
||||
$this->storage = Mockery::mock(StorageInterface::class);
|
||||
|
||||
$this->service = new ImageUploadService($this->repository, $this->storage);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Mockery::close();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function test_upload_fires_hooks(): void
|
||||
{
|
||||
// Arrange
|
||||
$beforeUploadFired = false;
|
||||
$afterUploadFired = false;
|
||||
$filterApplied = false;
|
||||
|
||||
HookManager::addAction('sirsoft-ckeditor5.image.before_upload', function () use (&$beforeUploadFired) {
|
||||
$beforeUploadFired = true;
|
||||
});
|
||||
|
||||
HookManager::addFilter('sirsoft-ckeditor5.image.filter_upload_file', function ($file) use (&$filterApplied) {
|
||||
$filterApplied = true;
|
||||
|
||||
return $file;
|
||||
});
|
||||
|
||||
HookManager::addAction('sirsoft-ckeditor5.image.after_upload', function () use (&$afterUploadFired) {
|
||||
$afterUploadFired = true;
|
||||
});
|
||||
|
||||
$file = UploadedFile::fake()->image('test.jpg');
|
||||
|
||||
$this->storage->shouldReceive('put')->andReturn(true);
|
||||
$this->storage->shouldReceive('getDisk')->andReturn('local');
|
||||
|
||||
$record = new Ckeditor5ImageUpload;
|
||||
$this->repository->shouldReceive('create')->andReturn($record);
|
||||
|
||||
// Act
|
||||
$this->service->upload($file, null);
|
||||
|
||||
// Assert
|
||||
$this->assertTrue($beforeUploadFired, 'before_upload hook should be fired');
|
||||
$this->assertTrue($filterApplied, 'filter_upload_file hook should be applied');
|
||||
$this->assertTrue($afterUploadFired, 'after_upload hook should be fired');
|
||||
|
||||
// Cleanup hooks
|
||||
HookManager::clearAction('sirsoft-ckeditor5.image.before_upload');
|
||||
HookManager::clearFilter('sirsoft-ckeditor5.image.filter_upload_file');
|
||||
HookManager::clearAction('sirsoft-ckeditor5.image.after_upload');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user