-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.x' into add-component-debug-command
- Loading branch information
Showing
100 changed files
with
2,524 additions
and
1,721 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symfony\UX\LiveComponent\Util; | ||
|
||
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent; | ||
use Symfony\UX\TwigComponent\ComponentStack; | ||
use Symfony\UX\TwigComponent\MountedComponent; | ||
|
||
/** | ||
* This class decorates the TwigComponent\ComponentStack adding specific Live component functionalities. | ||
* | ||
* @author Bart Vanderstukken <[email protected]> | ||
* | ||
* @internal | ||
*/ | ||
final class LiveComponentStack extends ComponentStack | ||
{ | ||
public function __construct(private readonly ComponentStack $componentStack) | ||
{ | ||
} | ||
|
||
public function getCurrentLiveComponent(): ?MountedComponent | ||
{ | ||
foreach ($this->componentStack as $mountedComponent) { | ||
if ($this->isLiveComponent($mountedComponent->getComponent()::class)) { | ||
return $mountedComponent; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
private function isLiveComponent(string $classname): bool | ||
{ | ||
return [] !== (new \ReflectionClass($classname))->getAttributes(AsLiveComponent::class); | ||
} | ||
|
||
public function getCurrentComponent(): ?MountedComponent | ||
{ | ||
return $this->componentStack->getCurrentComponent(); | ||
} | ||
|
||
public function getParentComponent(): ?MountedComponent | ||
{ | ||
return $this->componentStack->getParentComponent(); | ||
} | ||
|
||
public function hasParentComponent(): bool | ||
{ | ||
return $this->componentStack->hasParentComponent(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/LiveComponent/tests/Fixtures/Component/InputComponent.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\UX\LiveComponent\Tests\Fixtures\Component; | ||
|
||
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; | ||
|
||
/** | ||
* @author Bart Vanderstukken <[email protected]> | ||
*/ | ||
#[AsTwigComponent('input_component')] | ||
final class InputComponent | ||
{ | ||
} |
Oops, something went wrong.