From c7ec8f16b5449daadb092372b468dd3dd23147bf Mon Sep 17 00:00:00 2001 From: Lee Bradley <60924897+lbradley-mm@users.noreply.github.com> Date: Thu, 10 Apr 2025 17:16:16 +0100 Subject: [PATCH] DBBaseResource: Adds a better `::exists()` check Checks for actual JSON data --- src/FieldType/DBBaseResource.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/FieldType/DBBaseResource.php b/src/FieldType/DBBaseResource.php index b964b17..30d9175 100644 --- a/src/FieldType/DBBaseResource.php +++ b/src/FieldType/DBBaseResource.php @@ -68,6 +68,17 @@ abstract class DBBaseResource extends DBText */ protected $asset = null; + /** + * Only show as exists if the JSON is valid. + * @todo: Use `json_validate()` once it exists maybe?? + * + * {@inheritdoc} + */ + public function exists() + { + return parent::exists() && $this->getJSON(); + } + /** * @return stdClass */ @@ -115,7 +126,7 @@ protected function convertRawTransformations($transformation) return $carry; }, []); } - + /** * @param string $abbr * @return string