From 61ee1597fd09b42cf7bff6010c72f9662b1c5dd9 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 1 Mar 2022 11:51:57 +1300 Subject: [PATCH] NEW Use embed/embed v4 --- code/Exceptions/InvalidUrlException.php | 9 +++++++++ code/Extensions/RemoteFileModalExtension.php | 5 +++-- code/Forms/RemoteFileFormFactory.php | 2 +- composer.json | 2 +- tests/php/Forms/RemoteFileFormFactoryTest.php | 4 +++- 5 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 code/Exceptions/InvalidUrlException.php diff --git a/code/Exceptions/InvalidUrlException.php b/code/Exceptions/InvalidUrlException.php new file mode 100644 index 000000000..fcfaf79bb --- /dev/null +++ b/code/Exceptions/InvalidUrlException.php @@ -0,0 +1,9 @@ +remoteEditForm(); return $this->getSchemaResponse($schemaID, $form); - } catch (InvalidUrlException $exception) { + } catch (NetworkException | RequestException $exception) { $errors = ValidationResult::create() ->addError($exception->getMessage()); // @todo - Don't create dummy form (pass $form = null) diff --git a/code/Forms/RemoteFileFormFactory.php b/code/Forms/RemoteFileFormFactory.php index 1ad76245f..75ae2729d 100644 --- a/code/Forms/RemoteFileFormFactory.php +++ b/code/Forms/RemoteFileFormFactory.php @@ -2,8 +2,8 @@ namespace SilverStripe\AssetAdmin\Forms; -use Embed\Exceptions\InvalidUrlException; use InvalidArgumentException; +use SilverStripe\AssetAdmin\Exceptions\InvalidUrlException; use SilverStripe\Control\Director; use SilverStripe\Control\RequestHandler; use SilverStripe\Core\Config\Configurable; diff --git a/composer.json b/composer.json index 9af71b021..004bff67d 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "BSD-3-Clause", "require": { "php": "^7.4 || ^8.0", - "silverstripe/framework": "^4.10", + "silverstripe/framework": "^4.11", "silverstripe/admin": "^1.7", "silverstripe/graphql": "^3.5 || ^4" }, diff --git a/tests/php/Forms/RemoteFileFormFactoryTest.php b/tests/php/Forms/RemoteFileFormFactoryTest.php index 3be0dabdf..10b74dab5 100644 --- a/tests/php/Forms/RemoteFileFormFactoryTest.php +++ b/tests/php/Forms/RemoteFileFormFactoryTest.php @@ -2,7 +2,9 @@ namespace SilverStripe\AssetAdmin\Tests\Forms; -use Embed\Exceptions\InvalidUrlException; +use Embed\Http\NetworkException; +use Embed\Http\RequestException; +use SilverStripe\AssetAdmin\Exceptions\InvalidUrlException; use SilverStripe\AssetAdmin\Forms\RemoteFileFormFactory; use SilverStripe\AssetAdmin\Tests\Forms\RemoteFileFormFactoryTest\MockEmbed; use SilverStripe\Core\Injector\Injector;