From a144c4b5bd3d03c444519efee491caa67d188fa9 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Tue, 12 Nov 2024 17:08:58 +1300 Subject: [PATCH] ENH Update code to reflect changes in silverstripe/admin --- code/Controller/AssetAdmin.php | 8 ++++---- code/Extensions/RemoteFileModalExtension.php | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/code/Controller/AssetAdmin.php b/code/Controller/AssetAdmin.php index 618c3139f..8dc6c45dc 100644 --- a/code/Controller/AssetAdmin.php +++ b/code/Controller/AssetAdmin.php @@ -7,6 +7,7 @@ use SilverStripe\Admin\CMSBatchActionHandler; use SilverStripe\Admin\LeftAndMain; use SilverStripe\Admin\LeftAndMainFormRequestHandler; +use SilverStripe\Admin\ModalController; use SilverStripe\AssetAdmin\BatchAction\DeleteAssets; use SilverStripe\AssetAdmin\Forms\AssetFormFactory; use SilverStripe\AssetAdmin\Forms\FileFormFactory; @@ -212,6 +213,7 @@ public function getClientConfig(): array $validator = $this->getUpload()->getValidator(); $parentClientConfig = parent::getClientConfig(); + $modalController = ModalController::singleton(); return array_merge($parentClientConfig, [ 'reactRouter' => true, 'bustCache' => static::config()->get('bust_cache'), @@ -282,12 +284,10 @@ public function getClientConfig(): array 'schemaUrl' => $this->Link('schema/fileInsertForm') ], 'remoteEditForm' => [ - 'schemaUrl' => LeftAndMain::singleton() - ->Link('Modals/remoteEditFormSchema'), + 'schemaUrl' => $modalController->Link('remoteEditFormSchema'), ], 'remoteCreateForm' => [ - 'schemaUrl' => LeftAndMain::singleton() - ->Link('methodSchema/Modals/remoteCreateForm') + 'schemaUrl' => $modalController->Link('schema/remoteCreateForm') ], 'fileSelectForm' => [ 'schemaUrl' => $this->Link('schema/fileSelectForm') diff --git a/code/Extensions/RemoteFileModalExtension.php b/code/Extensions/RemoteFileModalExtension.php index b1633a832..1c94b5969 100644 --- a/code/Extensions/RemoteFileModalExtension.php +++ b/code/Extensions/RemoteFileModalExtension.php @@ -4,6 +4,7 @@ use Embed\Http\NetworkException; use Embed\Http\RequestException; +use SilverStripe\Admin\FormSchemaController; use SilverStripe\Admin\LeftAndMain; use SilverStripe\Admin\ModalController; use SilverStripe\AssetAdmin\Forms\RemoteFileFormFactory; @@ -36,7 +37,7 @@ class RemoteFileModalExtension extends Extension */ protected function getRequest() { - return $this->getOwner()->getController()->getRequest(); + return $this->getOwner()->getRequest(); } /** @@ -119,7 +120,7 @@ public function remoteEditFormSchema(HTTPRequest $request) */ protected function getSchemaResponse($schemaID, $form = null, ValidationResult $errors = null, $extraData = []) { - $parts = $this->getRequest()->getHeader(LeftAndMain::SCHEMA_HEADER); + $parts = $this->getRequest()->getHeader(FormSchemaController::SCHEMA_HEADER); $data = $this ->getFormSchema() ->getMultipartSchema($parts, $schemaID, $form, $errors);