From 5e6bce3fa8aa007134688c974a415948e14161ad Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Wed, 12 Aug 2020 19:50:30 +0200 Subject: [PATCH 1/2] Cleanup for "Should Field be rendered as Twig?" --- src/Entity/Field.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Entity/Field.php b/src/Entity/Field.php index 6c9baaf67..7631af518 100644 --- a/src/Entity/Field.php +++ b/src/Entity/Field.php @@ -235,8 +235,8 @@ public function getTwigValue() $value = $this->getContent()->sanitise($value); } - if (is_string($value) && $this->getDefinition()->get('allow_twig')) { - $twig = $this->getTwig(); + if ($this->shouldBeRenderedAsTwig($value)) { + $twig = $this->getContent()->getTwig(); if ($twig) { $template = $twig->createTemplate($value); @@ -256,11 +256,9 @@ public function getTwigValue() return $value; } - public function getTwig() + private function shouldBeRenderedAsTwig($value):bool { - if ($this->getContent()->getTwig()) { - return $this->getContent()->getTwig(); - } + return is_string($value) && $this->getDefinition()->get('allow_twig') && preg_match('/{[{%#]/', $value); } public function set(string $key, $value): self From 0d725354e6488db31a172908420562c6789714b7 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Thu, 13 Aug 2020 09:31:59 +0200 Subject: [PATCH 2/2] Temporarily fixate symplify/easy-coding-standard on 8.2.1, until we fix it properly --- composer.json | 2 +- src/Entity/Field.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index a6930a450..34e97234e 100644 --- a/composer.json +++ b/composer.json @@ -104,7 +104,7 @@ "se/selenium-server-standalone": "^3.141", "symfony/browser-kit": "^4.4 | ^5.1", "symfony/css-selector": "^4.4 | ^5.1", - "symplify/easy-coding-standard": "^8.1.10", + "symplify/easy-coding-standard": "8.2.1", "vaimo/binary-chromedriver": "^5.0" }, "config": { diff --git a/src/Entity/Field.php b/src/Entity/Field.php index 7631af518..13d6dedc5 100644 --- a/src/Entity/Field.php +++ b/src/Entity/Field.php @@ -256,7 +256,7 @@ public function getTwigValue() return $value; } - private function shouldBeRenderedAsTwig($value):bool + private function shouldBeRenderedAsTwig($value): bool { return is_string($value) && $this->getDefinition()->get('allow_twig') && preg_match('/{[{%#]/', $value); }