From 369ba2f0cb9ef14d59810418011c731f7feca098 Mon Sep 17 00:00:00 2001 From: Awilum Date: Tue, 13 Sep 2022 09:40:38 +0300 Subject: [PATCH] feat(directive): add ability to disabled expressions using `!expressions` --- .../core/Entries/Directives/ExpressionsDirective.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/flextype/core/Entries/Directives/ExpressionsDirective.php b/src/flextype/core/Entries/Directives/ExpressionsDirective.php index 05ced1af..021ea1d0 100644 --- a/src/flextype/core/Entries/Directives/ExpressionsDirective.php +++ b/src/flextype/core/Entries/Directives/ExpressionsDirective.php @@ -16,6 +16,7 @@ declare(strict_types=1); namespace Flextype\Entries\Directives; +use function Glowy\Strings\strings; use function Flextype\emitter; use function Flextype\entries; use function Flextype\parsers; @@ -24,6 +25,7 @@ use function Flextype\collection; // Directive: [[ ]] [% %] [# #] emitter()->addListener('onEntriesFetchSingleField', static function (): void { + if (! registry()->get('flextype.settings.entries.directives.expressions.enabled')) { return; } @@ -34,6 +36,10 @@ emitter()->addListener('onEntriesFetchSingleField', static function (): void { $field = entries()->registry()->get('methods.fetch.field'); + if (is_string($field['value']) && strings($field['value'])->contains('!expressions')) { + return; + } + $vars = []; // Convert entry fields to vars.