-
-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #2168 [TwigComponent] Use a RuntimeExtension (smnandre)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [TwigComponent] Use a RuntimeExtension * Hide implementation & start decoupling the template from the event system * Optimize (a bit) the ComponentNode Commits ------- 8e99e14 [TwigComponent] Use a RuntimeExtension
- Loading branch information
Showing
6 changed files
with
91 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\UX\TwigComponent\Twig; | ||
|
||
use Symfony\UX\TwigComponent\ComponentRenderer; | ||
use Symfony\UX\TwigComponent\Event\PreRenderEvent; | ||
|
||
/** | ||
* @author Kevin Bond <kevinbond@gmail.com> | ||
* @author Simon André <smn.andre@gmail.com> | ||
* | ||
* @internal | ||
*/ | ||
final class ComponentRuntime | ||
{ | ||
public function __construct( | ||
private readonly ComponentRenderer $renderer, | ||
) { | ||
} | ||
|
||
/** | ||
* @param array<string, mixed> $props | ||
*/ | ||
public function render(string $name, array $props = []): string | ||
{ | ||
return $this->renderer->createAndRender($name, $props); | ||
} | ||
|
||
/** | ||
* @param array<string, mixed> $props | ||
*/ | ||
public function preRender(string $name, array $props): ?string | ||
{ | ||
return $this->renderer->preCreateForRender($name, $props); | ||
} | ||
|
||
/** | ||
* @param array<string, mixed> $props | ||
* @param array<string, mixed> $context | ||
*/ | ||
public function startEmbedComponent(string $name, array $props, array $context, string $hostTemplateName, int $index): PreRenderEvent | ||
{ | ||
return $this->renderer->startEmbeddedComponentRender($name, $props, $context, $hostTemplateName, $index); | ||
} | ||
|
||
public function finishEmbedComponent(): void | ||
{ | ||
$this->renderer->finishEmbeddedComponentRender(); | ||
} | ||
} |
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