Skip to content

Commit bda474a

Browse files
committed
[Live] Rename BeforeReRender attribute to PreReRender
1 parent 18b194b commit bda474a

File tree

8 files changed

+13
-11
lines changed

8 files changed

+13
-11
lines changed

src/LiveComponent/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
is a BC break if you've created custom hydrators. They'll need to be converted to
3232
normalizers.
3333

34+
- [BC BREAK] Rename `BeforeReRender` attribute to `PreReRender`.
35+
3436
## 2.0.0
3537

3638
- Support for `stimulus` version 2 was removed and support for `@hotwired/stimulus`

src/LiveComponent/src/Attribute/AsLiveComponent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ public static function isActionAllowed(object $component, string $action): bool
8686
*
8787
* @return \ReflectionMethod[]
8888
*/
89-
public static function beforeReRenderMethods(object $component): \Traversable
89+
public static function preReRenderMethods(object $component): \Traversable
9090
{
91-
yield from self::attributeMethodsFor(BeforeReRender::class, $component);
91+
yield from self::attributeMethodsFor(PreReRender::class, $component);
9292
}
9393

9494
/**

src/LiveComponent/src/Attribute/BeforeReRender.php renamed to src/LiveComponent/src/Attribute/PreReRender.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
* @experimental
2121
*/
2222
#[\Attribute(\Attribute::TARGET_METHOD)]
23-
final class BeforeReRender
23+
final class PreReRender
2424
{
2525
}

src/LiveComponent/src/ComponentWithFormTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\Form\FormInterface;
1616
use Symfony\Component\Form\FormView;
1717
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
18-
use Symfony\UX\LiveComponent\Attribute\BeforeReRender;
18+
use Symfony\UX\LiveComponent\Attribute\PreReRender;
1919
use Symfony\UX\LiveComponent\Attribute\LiveProp;
2020
use Symfony\UX\LiveComponent\Util\LiveFormUtility;
2121
use Symfony\UX\TwigComponent\Attribute\ExposeInTemplate;
@@ -99,7 +99,7 @@ public function postMount(array $data): array
9999
* But, in the event that there is an action and the form was
100100
* not submitted manually, it will be submitted here.
101101
*/
102-
#[BeforeReRender]
102+
#[PreReRender]
103103
public function submitFormOnRender(): void
104104
{
105105
if (!$this->getFormInstance()->isSubmitted()) {

src/LiveComponent/src/EventListener/LiveComponentSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private function createResponse(MountedComponent $mounted, Request $request): Re
241241
{
242242
$component = $mounted->getComponent();
243243

244-
foreach (AsLiveComponent::beforeReRenderMethods($component) as $method) {
244+
foreach (AsLiveComponent::preReRenderMethods($component) as $method) {
245245
$component->{$method->name}();
246246
}
247247

src/LiveComponent/tests/Fixtures/Component/Component2.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\HttpFoundation\RedirectResponse;
1515
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
1616
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
17-
use Symfony\UX\LiveComponent\Attribute\BeforeReRender;
17+
use Symfony\UX\LiveComponent\Attribute\PreReRender;
1818
use Symfony\UX\LiveComponent\Attribute\LiveAction;
1919
use Symfony\UX\LiveComponent\Attribute\LiveProp;
2020
use Symfony\UX\LiveComponent\Attribute\PostHydrate;
@@ -63,7 +63,7 @@ public function postHydrateMethod(): void
6363
$this->postHydrateCalled = true;
6464
}
6565

66-
#[BeforeReRender]
66+
#[PreReRender]
6767
public function beforeReRenderMethod(): void
6868
{
6969
$this->beforeReRenderCalled = true;

src/LiveComponent/tests/Fixtures/Component/Component4.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Component;
1313

14-
use Symfony\UX\LiveComponent\Attribute\BeforeReRender;
14+
use Symfony\UX\LiveComponent\Attribute\PreReRender;
1515
use Symfony\UX\LiveComponent\Attribute\LiveAction;
1616
use Symfony\UX\LiveComponent\Attribute\LiveProp;
1717
use Symfony\UX\LiveComponent\Attribute\PostHydrate;
@@ -39,7 +39,7 @@ public function method2()
3939
{
4040
}
4141

42-
#[BeforeReRender]
42+
#[PreReRender]
4343
public function method3()
4444
{
4545
}

src/LiveComponent/tests/Unit/Attribute/AsLiveComponentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testCanGetPostHydrateMethods(): void
4747

4848
public function testCanGetBeforeReRenderMethods(): void
4949
{
50-
$methods = iterator_to_array(AsLiveComponent::beforeReRenderMethods(new Component5()));
50+
$methods = iterator_to_array(AsLiveComponent::preReRenderMethods(new Component5()));
5151

5252
$this->assertCount(1, $methods);
5353
$this->assertSame('method3', $methods[0]->getName());

0 commit comments

Comments
 (0)