Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
php: ['8.2', '8.3']
sylius: ["~2.0.0"]
sylius: ["~2.0.0", "~2.1.0"]

steps:
- name: Setup PHP
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DEFAULT_GOAL := help
SHELL=/bin/bash
APP_DIR=tests/Application
SYLIUS_VERSION=2.0.0
SYLIUS_VERSION=2.1.0
SYMFONY=cd ${APP_DIR} && symfony
COMPOSER=symfony composer
CONSOLE=${SYMFONY} console
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This plugin adds a rich editor on the fields you want. Now you can manage your c

| Sylius Version | PHP Version |
|----------------|-----------------|
| 2.0 | 8.1 - 8.2 |
| 2.0, 2.1 | 8.1 - 8.2 |

ℹ️ For Sylius 1.x, see our branch [branch 2.x] (https://github.com/monsieurbiz/SyliusRichEditorPlugin/tree/2.0) and all 2.x releases.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"require": {
"php": "^8.2",
"sylius/sylius": "~2.0.0",
"sylius/sylius": "~2.0",
"twig/markdown-extra": "^3.13",
"twig/extra-bundle": "^3.13",
"league/commonmark": "^2.6"
Expand Down
5 changes: 5 additions & 0 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ services:
# Maker
MonsieurBiz\SyliusRichEditorPlugin\Maker\UiElementMaker:
tags: ['maker.command']

MonsieurBiz\SyliusRichEditorPlugin\Twig\Components\UiElementForm:
autoconfigure: false
tags:
- { name: 'sylius.live_component.admin', key: 'SyliusAdmin:MonsieurBizUiElement:Form', template: '@MonsieurBizSyliusRichEditorPlugin/Admin/formContainer.html.twig' }
13 changes: 8 additions & 5 deletions src/Twig/Components/UiElementForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
namespace MonsieurBiz\SyliusRichEditorPlugin\Twig\Components;

use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveAction;
use Symfony\UX\LiveComponent\Attribute\LiveArg;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
Expand All @@ -26,8 +25,7 @@
use Symfony\UX\LiveComponent\DefaultActionTrait;
use Symfony\UX\LiveComponent\LiveCollectionTrait;

#[AsLiveComponent(name: 'SyliusAdmin:MonsieurBizUiElement:Form', template: '@MonsieurBizSyliusRichEditorPlugin/Admin/formContainer.html.twig')]
class UiElementForm extends AbstractController
class UiElementForm
{
use ComponentToolsTrait;
use ComponentWithFormTrait;
Expand All @@ -52,6 +50,11 @@ class UiElementForm extends AbstractController
#[LiveProp]
public ?string $locale = null;

public function __construct(
protected readonly FormFactoryInterface $formFactory,
) {
}

#[LiveAction]
public function addCollectionItem(PropertyAccessorInterface $propertyAccessor, #[LiveArg] string $name): void
{
Expand All @@ -68,7 +71,7 @@ public function removeCollectionItem(PropertyAccessorInterface $propertyAccessor

protected function instantiateForm(): FormInterface
{
return $this->createForm(
return $this->formFactory->create(
$this->uiElementFormClass ?? throw new RuntimeException('Ui Element form class is not defined'),
$this->data,
);
Expand Down
Loading