diff --git a/_config/types.yml b/_config/types.yml index 5007448b..ea32716c 100644 --- a/_config/types.yml +++ b/_config/types.yml @@ -5,14 +5,14 @@ Name: linkfield-types SilverStripe\Link\Type\Registry: types: cms: - classname: SilverStripe\Link\SiteTreeLink + classname: SilverStripe\Link\Models\SiteTreeLink enabled: true external: - classname: SilverStripe\Link\ExternalLink + classname: SilverStripe\Link\Models\ExternalLink enabled: true file: - classname: SilverStripe\Link\FileLink + classname: SilverStripe\Link\Models\FileLink enabled: true email: - classname: SilverStripe\Link\EmailLink + classname: SilverStripe\Link\Models\EmailLink enabled: true diff --git a/src/Extensions/AjaxField.php b/src/Extensions/AjaxField.php index 9c1ea7c5..03b453f2 100644 --- a/src/Extensions/AjaxField.php +++ b/src/Extensions/AjaxField.php @@ -4,12 +4,13 @@ use SilverStripe\Core\Extension; use SilverStripe\Forms\FormField; -use SilverStripe\Link; /** - * Tweak fields that need to be serve through the DynamicLink form schema and need to be able to receive AJAX calls. + * Tweak fields that need to be served through the DynamicLink form schema and need to be able to receive AJAX calls. * * For example the TreeDropdownField need to be able to receive AJAX request to fetch the list of available SiteTrees. + * + * This is a bit hackish. There's probably a less dumb way of doing this. */ class AjaxField extends Extension { diff --git a/src/Extensions/ModalController.php b/src/Extensions/ModalController.php index 8e83e55e..53bdca10 100644 --- a/src/Extensions/ModalController.php +++ b/src/Extensions/ModalController.php @@ -7,9 +7,8 @@ use SilverStripe\Control\HTTPResponse_Exception; use SilverStripe\Core\Extension; use SilverStripe\Forms\Form; -use SilverStripe\Link\FormFactory; +use SilverStripe\Link\Form\FormFactory; use SilverStripe\Link\Type\Registry; -use SilverStripe\View\Requirements; /** * Extensions to apply to ModalController so it knows how to handle the DynamicLink action. diff --git a/src/FormFactory.php b/src/Form/FormFactory.php similarity index 87% rename from src/FormFactory.php rename to src/Form/FormFactory.php index 789b3746..8ceac8fb 100644 --- a/src/FormFactory.php +++ b/src/Form/FormFactory.php @@ -1,13 +1,15 @@ dataValue(); - $value = is_array($dataValue) ? $dataValue : $this->parseString($this->dataValue()); + $value = is_string($dataValue) ? $this->parseString($this->dataValue()) : $dataValue; if ($class = DataObject::getSchema()->hasOneComponent(get_class($record), $fieldname)) { /** @var JsonData|DataObject $jsonDataObject */ diff --git a/src/LinkField.php b/src/Form/LinkField.php similarity index 63% rename from src/LinkField.php rename to src/Form/LinkField.php index 64ce2c7e..77377d70 100644 --- a/src/LinkField.php +++ b/src/Form/LinkField.php @@ -1,11 +1,10 @@ File ? $this->File->getURL() : ''; } - -// public function getCMSFields() -// { -// return parent::getCMSFields() -// ->addFieldToTab( -// 'Root.Main', -// TreeDropdownField::create( -// 'SiteTreeID', -// 'Page', -// SiteTree::class, -// 'ID', -// 'TreeTitle' -// ) -// ); -// } } diff --git a/src/Link.php b/src/Models/Link.php similarity index 93% rename from src/Link.php rename to src/Models/Link.php index 9c362887..d709aa0f 100644 --- a/src/Link.php +++ b/src/Models/Link.php @@ -1,18 +1,22 @@ + * Load the link data into a singleton Link Object * * @return DBHTMLText */ diff --git a/templates/SilverStripe/Link/JsonField.ss b/templates/SilverStripe/Link/Form/JsonField.ss similarity index 100% rename from templates/SilverStripe/Link/JsonField.ss rename to templates/SilverStripe/Link/Form/JsonField.ss diff --git a/templates/SilverStripe/Link/Link.ss b/templates/SilverStripe/Link/Models/Link.ss similarity index 100% rename from templates/SilverStripe/Link/Link.ss rename to templates/SilverStripe/Link/Models/Link.ss