1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-07 21:56:33 +02:00

feat(expressions): add new field and var expressions

This commit is contained in:
Awilum
2022-05-29 11:11:53 +03:00
parent da3b93b940
commit c3619c65b4
6 changed files with 104 additions and 0 deletions

View File

@@ -106,6 +106,12 @@ entries:
csrf:
enabled: true
class: "Flextype\\Entries\\Expressions\\CsrfExpression"
var:
enabled: true
class: "Flextype\\Entries\\Expressions\\VarExpression"
field:
enabled: true
class: "Flextype\\Entries\\Expressions\\FieldExpression"
directives:
expressions:
enabled: true

View File

@@ -0,0 +1,16 @@
<?php
use Flextype\Component\Filesystem\Filesystem;
beforeEach(function() {
filesystem()->directory(PATH['project'] . '/entries')->create();
});
afterEach(function (): void {
filesystem()->directory(PATH['project'] . '/entries')->delete();
});
test('field expression', function () {
entries()->create('field', ['test' => '[[ field("id") ]]']);
expect(entries()->fetch('field')['test'])->toBe('field');
});

View File

@@ -0,0 +1,16 @@
<?php
use Flextype\Component\Filesystem\Filesystem;
beforeEach(function() {
filesystem()->directory(PATH['project'] . '/entries')->create();
});
afterEach(function (): void {
filesystem()->directory(PATH['project'] . '/entries')->delete();
});
test('var expression', function () {
entries()->create('var', ['vars' => ['foo' => 'Foo'], 'test' => '[[ var("foo") ]]']);
expect(entries()->fetch('var')['test'])->toBe('Foo');
});