From 0aad5b16d5895a34b61ad5b5b72dfaabeeaed8ce Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 27 Sep 2023 11:35:18 +1300 Subject: [PATCH] API Remove DBLink and DBJson --- README.md | 5 --- _config.php | 1 - src/ORM/DBJson.php | 76 ---------------------------------------------- src/ORM/DBLink.php | 36 ---------------------- 4 files changed, 118 deletions(-) delete mode 100644 src/ORM/DBJson.php delete mode 100644 src/ORM/DBLink.php diff --git a/README.md b/README.md index 90fa633f..2b7943c2 100644 --- a/README.md +++ b/README.md @@ -46,10 +46,6 @@ use SilverStripe\LinkField\Form\LinkField; class Page extends SiteTree { - private static array $db = [ - 'DbLink' => DBLink::class - ]; - private static array $has_one = [ 'HasOneLink' => Link::class, ]; @@ -62,7 +58,6 @@ class Page extends SiteTree 'Root.Main', [ LinkField::create('HasOneLink'), - LinkField::create('DbLink'), ] ) diff --git a/_config.php b/_config.php index 9e519d4a..71c7914c 100644 --- a/_config.php +++ b/_config.php @@ -5,5 +5,4 @@ // Avoid creating global variables call_user_func(function () { - }); diff --git a/src/ORM/DBJson.php b/src/ORM/DBJson.php deleted file mode 100644 index 9e6391b1..00000000 --- a/src/ORM/DBJson.php +++ /dev/null @@ -1,76 +0,0 @@ -defaultVal = is_array($defaultVal) ? $defaultVal : []; - - parent::__construct($name); - } - - public function requireField() - { - $charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset'); - $collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation'); - - $parts = [ - 'datatype' => 'mediumtext', - 'character set' => $charset, - 'collate' => $collation, - 'arrayValue' => $this->arrayValue - ]; - - $values = [ - 'type' => 'text', - 'parts' => $parts - ]; - - DB::require_field($this->tableName, $this->name, $values); - } - - public function nullValue() - { - return null; - } - - public function setValue($value, $record = null, $markChanged = true) - { - if (!$value) { - $value = null; - } - - if (is_string($value)) { - $value = json_decode($value, true); - } elseif ($value instanceof JsonData) { - $value = $value->jsonSerialize(); - } - - return parent::setValue($value, $record, $markChanged); - } - - public function prepValueForDB($value) - { - if (is_array($value) || $value instanceof JsonData) { - $value = json_encode($value); - } - - return $value; - } - - public function scalarValueOnly() - { - return false; - } -} diff --git a/src/ORM/DBLink.php b/src/ORM/DBLink.php deleted file mode 100644 index a5889434..00000000 --- a/src/ORM/DBLink.php +++ /dev/null @@ -1,36 +0,0 @@ -getValue(); - - if ($value) { - $type = Registry::singleton()->byKey($value['typeKey']); - - if ($type) { - return $type->loadLinkData($value)->forTemplate(); - } - } - } - - public function scaffoldFormField($title = null, $params = null) - { - return LinkField::create($this->getName(), $this->getValue()); - } -}