Skip to content

Commit 19de0cb

Browse files
authored
Merge pull request #8 from tattersoftware/body-bug
Prevent {body} token inheriting
2 parents cdf3775 + f91547b commit 19de0cb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Entities/Template.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ public function getTokens(): array
6868

6969
if ($parent = $this->getParent())
7070
{
71-
$matches[1] = array_unique(array_merge($parent->getTokens(), $matches[1]));
71+
// Prepend parent tokens (minus {body})
72+
$parentTokens = array_diff($parent->getTokens(), ['body']);
73+
$matches[1] = array_unique(array_merge($parentTokens, $matches[1]));
7274
}
7375

7476
return $matches[1];

tests/entities/ParentTemplateTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public function setUp(): void
4747

4848
public function testChildIncludesParentTokens()
4949
{
50-
$expected = ['subject', 'body', 'foobar', 'number'];
50+
// Notice that {body} is intentionally excluded
51+
$expected = ['subject', 'foobar', 'number'];
5152
$result = $this->template->getTokens();
5253

5354
$this->assertEquals($expected, array_values($result));

0 commit comments

Comments
 (0)