Skip to content

Commit

Permalink
[5.x] Ensures values are resolved when checking Antlers parsing setti…
Browse files Browse the repository at this point in the history
…ngs (#10003)
  • Loading branch information
JohnathonKoster authored May 7, 2024
1 parent 9d49f3b commit b199ddf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Fields/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public function getIterator()

public function shouldParseAntlers()
{
$this->resolve();

return $this->fieldtype && $this->fieldtype->config('antlers');
}

Expand Down Expand Up @@ -147,6 +149,8 @@ public function antlersValue(Parser $parser, $variables)

public function field()
{
$this->resolve();

return $this->fieldtype->field();
}

Expand Down
22 changes: 22 additions & 0 deletions tests/Antlers/Runtime/RuntimeValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Tests\Antlers\Runtime;

use Facades\Statamic\Fields\BlueprintRepository;
use Facades\Tests\Factories\EntryFactory;
use Statamic\Entries\Entry;
use Statamic\Facades;
use Statamic\Facades\Collection;
use Statamic\Facades\GlobalSet;
use Statamic\Tags\Tags;
use Statamic\View\Antlers\Language\Utilities\StringUtilities;
use Tests\Antlers\ParserTestCase;
Expand Down Expand Up @@ -63,4 +66,23 @@ public function mePlease()

$this->assertSame($expected, $content);
}

public function test_fieldtype_information_is_resolved_when_augmenting()
{
// https://github.com/statamic/cms/issues/10001

$blueprint = Facades\Blueprint::makeFromFields([
'the_text' => ['type' => 'text', 'antlers' => true],
]);

BlueprintRepository::shouldReceive('find')->with('globals.the_global')->andReturn($blueprint);

$global = GlobalSet::make('the_global');
$variables = $global->makeLocalization('en');

$variables->set('the_text', 'The Value');
$theText = $variables->toDeferredAugmentedArray()['the_text'];

$this->assertTrue($theText->shouldParseAntlers());
}
}

0 comments on commit b199ddf

Please sign in to comment.