Skip to content

Commit

Permalink
Simplify data passing to a component
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubtobiasz committed Feb 7, 2024
1 parent 2d1c684 commit c95ef0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/TwigHooks/src/Provider/ComponentDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function provide(AbstractHookable $hookable, array $hookData): array
{
return $this->mapArrayRecursively(function (mixed $value) use ($hookData): mixed {
if (is_string($value) && str_starts_with($value, '@=')) {
return $this->expressionLanguage->evaluate(substr($value, 2), ['data' => $hookData]);
return $this->expressionLanguage->evaluate(substr($value, 2), $hookData);
}

return $value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public function testItReturnsDataFromHookable(): void

public function testItPassesTemplateLevelDataToExpressionLanguage(): void
{
$hookable = BaseHookableMotherObject::withData(['some_key' => '@=data["some"]']);
$hookable = BaseHookableMotherObject::withData(['some_key' => '@=some']);

$dataProvider = $this->createTestSubject();

$this->assertSame(['some_key' => 'data'], $dataProvider->provide($hookable, ['some' => 'data']));
$this->assertSame(['some_key' => 'data'], $dataProvider->provide($hookable, ['some' => 'data', 'another' => 'data']));
}

private function createTestSubject(): DataProviderInterface
Expand Down

0 comments on commit c95ef0c

Please sign in to comment.