Skip to content

[Live] Rename BeforeReRender attribute to PreReRender #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2022
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: 2 additions & 0 deletions src/LiveComponent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
is a BC break if you've created custom hydrators. They'll need to be converted to
normalizers.

- [BC BREAK] Rename `BeforeReRender` attribute to `PreReRender`.

## 2.0.0

- Support for `stimulus` version 2 was removed and support for `@hotwired/stimulus`
Expand Down
4 changes: 2 additions & 2 deletions src/LiveComponent/src/Attribute/AsLiveComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ public static function isActionAllowed(object $component, string $action): bool
*
* @return \ReflectionMethod[]
*/
public static function beforeReRenderMethods(object $component): \Traversable
public static function preReRenderMethods(object $component): \Traversable
{
yield from self::attributeMethodsFor(BeforeReRender::class, $component);
yield from self::attributeMethodsFor(PreReRender::class, $component);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
* @experimental
*/
#[\Attribute(\Attribute::TARGET_METHOD)]
final class BeforeReRender
final class PreReRender
{
}
4 changes: 2 additions & 2 deletions src/LiveComponent/src/ComponentWithFormTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
use Symfony\UX\LiveComponent\Attribute\BeforeReRender;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
use Symfony\UX\LiveComponent\Attribute\PreReRender;
use Symfony\UX\LiveComponent\Util\LiveFormUtility;
use Symfony\UX\TwigComponent\Attribute\ExposeInTemplate;
use Symfony\UX\TwigComponent\Attribute\PostMount;
Expand Down Expand Up @@ -99,7 +99,7 @@ public function postMount(array $data): array
* But, in the event that there is an action and the form was
* not submitted manually, it will be submitted here.
*/
#[BeforeReRender]
#[PreReRender]
public function submitFormOnRender(): void
{
if (!$this->getFormInstance()->isSubmitted()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private function createResponse(MountedComponent $mounted, Request $request): Re
{
$component = $mounted->getComponent();

foreach (AsLiveComponent::beforeReRenderMethods($component) as $method) {
foreach (AsLiveComponent::preReRenderMethods($component) as $method) {
$component->{$method->name}();
}

Expand Down
4 changes: 2 additions & 2 deletions src/LiveComponent/tests/Fixtures/Component/Component2.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\BeforeReRender;
use Symfony\UX\LiveComponent\Attribute\PreReRender;
use Symfony\UX\LiveComponent\Attribute\LiveAction;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
use Symfony\UX\LiveComponent\Attribute\PostHydrate;
Expand Down Expand Up @@ -63,7 +63,7 @@ public function postHydrateMethod(): void
$this->postHydrateCalled = true;
}

#[BeforeReRender]
#[PreReRender]
public function beforeReRenderMethod(): void
{
$this->beforeReRenderCalled = true;
Expand Down
4 changes: 2 additions & 2 deletions src/LiveComponent/tests/Fixtures/Component/Component4.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

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

use Symfony\UX\LiveComponent\Attribute\BeforeReRender;
use Symfony\UX\LiveComponent\Attribute\PreReRender;
use Symfony\UX\LiveComponent\Attribute\LiveAction;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
use Symfony\UX\LiveComponent\Attribute\PostHydrate;
Expand Down Expand Up @@ -39,7 +39,7 @@ public function method2()
{
}

#[BeforeReRender]
#[PreReRender]
public function method3()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testCanGetPostHydrateMethods(): void

public function testCanGetBeforeReRenderMethods(): void
{
$methods = iterator_to_array(AsLiveComponent::beforeReRenderMethods(new Component5()));
$methods = iterator_to_array(AsLiveComponent::preReRenderMethods(new Component5()));

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