Skip to content

Commit 535b184

Browse files
committed
feature #726 [TwigComponent] Move DataModelPropsSubscriber to LiveComponent (onEXHovia)
This PR was merged into the 2.x branch. Discussion ---------- [TwigComponent] Move DataModelPropsSubscriber to LiveComponent Parsing the "data-model" key useful only use LiveComponent, so let's move services from TwigComponent. Commits ------- ed7f936 [TwigComponent] Move DataModelPropsSubscriber to LiveComponent
2 parents 95cc2f5 + ed7f936 commit 535b184

File tree

10 files changed

+22
-19
lines changed

10 files changed

+22
-19
lines changed

src/LiveComponent/src/DependencyInjection/LiveComponentExtension.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Symfony\UX\LiveComponent\ComponentValidatorInterface;
2424
use Symfony\UX\LiveComponent\Controller\BatchActionController;
2525
use Symfony\UX\LiveComponent\EventListener\AddLiveAttributesSubscriber;
26+
use Symfony\UX\LiveComponent\EventListener\DataModelPropsSubscriber;
2627
use Symfony\UX\LiveComponent\EventListener\InterceptChildComponentRenderSubscriber;
2728
use Symfony\UX\LiveComponent\EventListener\LiveComponentSubscriber;
2829
use Symfony\UX\LiveComponent\EventListener\ResetDeterministicIdSubscriber;
@@ -89,6 +90,14 @@ function (ChildDefinition $definition, AsLiveComponent $attribute) {
8990
])
9091
;
9192

93+
$container->register('ux.live_component.event_listener.data_model_props_subscriber', DataModelPropsSubscriber::class)
94+
->addTag('kernel.event_subscriber')
95+
->setArguments([
96+
new Reference('ux.twig_component.component_stack'),
97+
new Reference('property_accessor'),
98+
])
99+
;
100+
92101
$container->register('ux.live_component.event_subscriber', LiveComponentSubscriber::class)
93102
->addTag('kernel.event_subscriber')
94103
->addTag('container.service_subscriber', ['key' => ComponentFactory::class, 'id' => 'ux.twig_component.component_factory'])

src/TwigComponent/src/EventListener/DataModelPropsSubscriber.php renamed to src/LiveComponent/src/EventListener/DataModelPropsSubscriber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\TwigComponent\EventListener;
12+
namespace Symfony\UX\LiveComponent\EventListener;
1313

1414
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1515
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
16+
use Symfony\UX\LiveComponent\Util\ModelBindingParser;
1617
use Symfony\UX\TwigComponent\ComponentStack;
1718
use Symfony\UX\TwigComponent\Event\PreMountEvent;
18-
use Symfony\UX\TwigComponent\Util\ModelBindingParser;
1919

2020
/**
2121
* Parses the "data-model" key, which triggers extra props to be passed in.

src/TwigComponent/src/Util/ModelBindingParser.php renamed to src/LiveComponent/src/Util/ModelBindingParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\TwigComponent\Util;
12+
namespace Symfony\UX\LiveComponent\Util;
1313

1414
/**
1515
* Parses the "data-model" format.

src/TwigComponent/tests/Fixtures/Component/ParentFormComponent.php renamed to src/LiveComponent/tests/Fixtures/Component/ParentFormComponent.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\TwigComponent\Tests\Fixtures\Component;
12+
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Component;
1313

14-
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
14+
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
15+
use Symfony\UX\LiveComponent\DefaultActionTrait;
1516

16-
#[AsTwigComponent('parent_form_component')]
17+
#[AsLiveComponent('parent_form_component')]
1718
final class ParentFormComponent
1819
{
20+
use DefaultActionTrait;
21+
1922
public ?string $content = null;
2023

2124
public ?string $content2 = null;

src/TwigComponent/tests/Fixtures/Component/TextareaComponent.php renamed to src/LiveComponent/tests/Fixtures/Component/TextareaComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\TwigComponent\Tests\Fixtures\Component;
12+
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Component;
1313

1414
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
1515

src/TwigComponent/tests/Integration/EventListener/DataModelPropsSubscriberTest.php renamed to src/LiveComponent/tests/Integration/EventListener/DataModelPropsSubscriberTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\TwigComponent\Tests\Integration;
12+
namespace Symfony\UX\LiveComponent\Tests\Integration;
1313

1414
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
1515
use Symfony\UX\TwigComponent\ComponentRenderer;

src/TwigComponent/tests/Unit/Util/ModelBindingParserTest.php renamed to src/LiveComponent/tests/Unit/Util/ModelBindingParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\UX\TwigComponent\Tests\Unit\Util;
12+
namespace Symfony\UX\LiveComponent\Tests\Unit\Util;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\UX\TwigComponent\Util\ModelBindingParser;
15+
use Symfony\UX\LiveComponent\Util\ModelBindingParser;
1616

1717
final class ModelBindingParserTest extends TestCase
1818
{

src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Symfony\UX\TwigComponent\ComponentRendererInterface;
2626
use Symfony\UX\TwigComponent\ComponentStack;
2727
use Symfony\UX\TwigComponent\DependencyInjection\Compiler\TwigComponentPass;
28-
use Symfony\UX\TwigComponent\EventListener\DataModelPropsSubscriber;
2928
use Symfony\UX\TwigComponent\Twig\ComponentExtension;
3029

3130
/**
@@ -76,13 +75,5 @@ class_exists(AbstractArgument::class) ? new AbstractArgument(sprintf('Added in %
7675
->addTag('container.service_subscriber', ['key' => ComponentRenderer::class, 'id' => 'ux.twig_component.component_renderer'])
7776
->addTag('container.service_subscriber', ['key' => ComponentFactory::class, 'id' => 'ux.twig_component.component_factory'])
7877
;
79-
80-
$container->register('ux.twig_component.event_listener.data_model_props_subscriber', DataModelPropsSubscriber::class)
81-
->addTag('kernel.event_subscriber')
82-
->setArguments([
83-
new Reference('ux.twig_component.component_stack'),
84-
new Reference('property_accessor'),
85-
])
86-
;
8778
}
8879
}

0 commit comments

Comments
 (0)