Skip to content

Commit

Permalink
Fix initial root hierarchy creation
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakyvv committed Aug 30, 2023
1 parent 98a4acc commit 1b6f89d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/TwigComponent/src/ComponentRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ private function preRender(MountedComponent $mounted, array $context = []): PreR
$component = $mounted->getComponent();

// add the "parent" component when rendering a nested embedded component
if (isset($context[PreRenderEvent::EMBEDDED]) && true === $context[PreRenderEvent::EMBEDDED]) {
$hierarchy = isset($context['this']) && $context['this'] instanceof Hierarchy ? $context['this'] : new Hierarchy($component);
if (isset($context[PreRenderEvent::EMBEDDED]) && true === $context[PreRenderEvent::EMBEDDED] && isset($context['this'])) {
$hierarchy = $context['this'] instanceof Hierarchy ? $context['this'] : new Hierarchy($context['this']);
if (isset($context['this'])) {
$hierarchy = $hierarchy->add($component);
}
Expand Down
4 changes: 2 additions & 2 deletions src/TwigComponent/tests/Integration/EmbeddedComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ public function testBlockDefinitionCanAccessTheContextOfTheDestinationBlocks():
);
}

public function testAccessingTheHierarchyToHighThrowsAnException(): void
public function testAccessingTheHierarchyTooHighThrowsAnException(): void
{
$this->expectExceptionMessage('Impossible to access an attribute ("foo") on a null variable');
$this->expectExceptionMessage('Neither the property "parent" nor one of the methods "parent()", "getparent()"/"isparent()"/"hasparent()" or "__call()" exist');
self::getContainer()->get(Environment::class)->render('embedded_component_hierarchy_exception.html.twig');
}

Expand Down

0 comments on commit 1b6f89d

Please sign in to comment.