소스 정보
- 저장소
- Guiziweb/guiziweb-plugins
- 최근 소스 활동
- 2026년 5월 24일 05:14
- 감지된 SKILL.md 언어
- 영어
- 스타
- 4
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/Guiziweb/guiziweb-plugins --skill add-images명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SKILL.md 표시 중
| name | add-images |
| description | Add a multiple images collection (OneToMany) to an existing Sylius Resource |
| argument-hint | [ModelName] |
| allowed-tools | AskUserQuestion, Bash, Read, Edit, Write, Glob, Grep |
Ask the user for the ModelName if not provided.
Prerequisite: /sylius-app:add-model must have been run first.
src/Entity/{ModelName}/{ModelName}Image.php:
<?php
declare(strict_types=1);
namespace App\Entity\{ModelName};
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\Image;
#[ORM\Entity]
#[ORM\Table(name: 'app_{model_snake}_image')]
class {ModelName}Image extends Image
{
#[ORM\ManyToOne(
targetEntity: {ModelName}::class,
inversedBy: 'images'
)]
#[ORM\JoinColumn(
name: 'owner_id',
referencedColumnName: 'id',
nullable: false,
onDelete: 'CASCADE'
)]
protected $owner = null;
}
Add ImagesAwareInterface and the images collection to the existing entity:
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Sylius\Component\Core\Model\ImageInterface;
use Sylius\Component\Core\Model\ImagesAwareInterface;
class {ModelName} implements {ModelName}Interface, ImagesAwareInterface
{
#[ORM\OneToMany(
targetEntity: {ModelName}Image::class,
mappedBy: 'owner',
orphanRemoval: true,
cascade: ['persist', 'remove', 'detach']
)]
private Collection $images;
public function __construct()
{
// keep existing constructor content
$this->images = new ArrayCollection();
}
public function ():
{
->images;
}
{
->images->(fn(ImageInterface ) => ->() === );
}
{
!->images->();
}
{
->images->();
}
{
(!->()) {
->();
->images->();
}
}
{
(->()) {
->();
->images->();
}
}
}
src/Form/Type/{ModelName}/{ModelName}ImageType.php:
<?php
declare(strict_types=1);
namespace App\Form\Type\{ModelName};
use App\Entity\{ModelName}\{ModelName}Image;
use Sylius\Bundle\CoreBundle\Form\Type\ImageType;
final class {ModelName}ImageType extends ImageType
{
public function __construct()
{
parent::__construct({ModelName}Image::class, ['sylius']);
}
public function getBlockPrefix(): string
{
return 'app_{model_snake}_image';
}
}
config/services.yamlservices:
app.form.type.{model_snake}_image:
class: App\Form\Type\{ModelName}\{ModelName}ImageType
tags:
- { name: form.type }
app.listener.images_upload.{model_snake}:
parent: sylius.listener.images_upload
autowire: true
public: false
tags:
- { name: kernel.event_listener, event: 'app.{model_snake}.pre_create', method: uploadImages }
- { name: kernel.event_listener, event: 'app.{model_snake}.pre_update', method: uploadImages }
The ResourceFormComponent is required for LiveCollectionType add/remove buttons to work — it wraps the form in a Live Component context. Register it only if it doesn't already exist:
bin/console debug:container --tag=sylius.live_component.admin | grep 'app:{model_snake}:form'
If the command returns nothing, append to config/services.yaml:
services:
app.twig.component.{model_snake}.form:
class: Sylius\Bundle\UiBundle\Twig\Component\ResourceFormComponent
arguments:
- '@app.repository.{model_snake}'
- '@form.factory'
- '%app.model.{model_snake}.class%'
- App\Form\Type\{ModelName}\{ModelName}Type
tags:
- { name: sylius.live_component.admin, key: 'app:{model_snake}:form' }
The event names use
app(Sylius 2.x resource events use the application prefix, notsylius.*).
Append to config/packages/sylius_resource.yaml:
sylius_resource:
resources:
app.{model_snake}_image:
classes:
model: App\Entity\{ModelName}\{ModelName}Image
form: App\Form\Type\{ModelName}\{ModelName}ImageType
images field to the main FormTypeIn the existing {ModelName}Type, add the images collection:
use Symfony\UX\LiveComponent\Form\Type\LiveCollectionType;
$builder->add('images', LiveCollectionType::class, [
'entry_type' => {ModelName}ImageType::class,
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'label' => 'sylius.ui.images',
]);
templates/admin/{model_snake}/form/sections/images.html.twig:
<div class="card mb-3">
<div class="card-header">
<div class="card-title">{{ 'sylius.ui.images'|trans }}</div>
</div>
<div class="card-body">
{% hook 'images' %}
</div>
</div>
templates/admin/{model_snake}/form/sections/images/content.html.twig:
{% set images = hookable_metadata.context.form.images %}
<div class="row">
{% for image_form in images %}
<div class="col-12 col-md-6 row mb-4">
<div class="col-auto">
<div>
{% if image_form.vars.value.path is not null %}
<span class="avatar avatar-xl" style="background-image: url('{{ image_form.vars.value.path|imagine_filter('sylius_small') }}')"></span>
{% else %}
<span class="avatar avatar-xl"></span>
{% endif %}
</div>
<div class="mt-3 d-flex items-center">
{{ form_widget(image_form.vars.button_delete, { label: 'sylius.ui.delete'|trans, attr: { class: 'btn btn-outline-danger w-100' }}) }}
</div>
</div>
<div class="col">
<div class="mb-3">
{{ form_row(image_form.file) }}
</div>
</div>
</div>
{% endfor %}
</div>
templates/admin/{model_snake}/form/sections/images/add_button.html.twig:
<div class="d-grid gap-2">
{{ form_widget(hookable_metadata.context.form.images.vars.button_add) }}
</div>
Hook files are split by action (create.yaml, update.yaml), one directory per resource — matching Sylius core convention.
Unified path: config/packages/twig_hooks/{model_snake}/create.yaml and update.yaml.
First-time setup: add (or extend) an imports: block at the top of config/packages/_sylius.yaml so the split files are loaded:
imports:
- { resource: "twig_hooks/**/*.yaml" }
If
create.yamlalready exists for this resource (e.g. fromadd-translatable-model), theform:block is already set — only add theimages:entry undercontent.form.sectionsand theimages.*sub-hook.
sylius_twig_hooks:
hooks:
'sylius_admin.{model_snake}.create.content':
form:
component: 'app:{model_snake}:form'
props:
resource: '@=_context.resource'
form: '@=_context.form'
template: '@SyliusAdmin/shared/crud/common/content/form.html.twig'
priority: 0
'sylius_admin.{model_snake}.create.content.form.sections':
images:
template: 'admin/{model_snake}/form/sections/images.html.twig'
priority: -100
'sylius_admin.{model_snake}.create.content.form.sections.images':
content:
template: 'admin/{model_snake}/form/sections/images/content.html.twig'
priority: 100
add_button:
template: 'admin/{model_snake}/form/sections/images/add_button.html.twig'
priority: 0
Same structure as create.yaml — replace every occurrence of .create. with .update..
On the image entity:
use Symfony\Component\Validator\Constraints as Assert;
#[Assert\Image(
groups: ['sylius'],
mimeTypes: ['image/png', 'image/jpeg', 'image/gif'],
maxSize: '10M'
)]
protected $file;
On the main entity:
use Symfony\Component\Validator\Constraints as Assert;
#[Assert\Valid]
private Collection $images;
bin/console doctrine:migrations:diff
Always review the generated migration before applying. doctrine:migrations:diff captures every difference between mapping and DB — including pre-existing schema drift unrelated to your image collection. The migration should only contain CREATE TABLE app_{model_snake}_image with its owner_id FK + indexes. If unrelated SQL is present (e.g. on messenger_messages or other Sylius core tables), trim the migration to keep only the image table — drift belongs to the project baseline, not your skill output.
Apply:
bin/console doctrine:migrations:migrate --no-interaction
bin/console cache:clear
bin/console sylius:debug:resource 'App\Entity\{ModelName}\{ModelName}Image' prints the image resource metadata (alias app.{model_snake}_image, model class, form type)bin/console doctrine:query:sql "DESCRIBE app_{model_snake}_image" lists the expected columns (id, owner_id, type, path)bin/console debug:container --tag=sylius.live_component.admin | grep 'app:{model_snake}:form' finds the live component keySOC 직업 분류 기준