Skip to content

Commit 87a587d

Browse files
authoredJun 8, 2023
Merge pull request sitegeist#128 from sitegeist/feature/removeLocalFileImage
[FEATURE] Deprecate LocalFile/LocalImage, use Fal instead
2 parents eb82264 + 1b13e66 commit 87a587d

File tree

7 files changed

+12
-7
lines changed

7 files changed

+12
-7
lines changed
 

‎Classes/Domain/Model/File.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public static function fromString(string $value): ?self
7979
try {
8080
return new RemoteFile($value);
8181
} catch (InvalidRemoteFileException $e) {
82-
return new LocalFile($value);
82+
$file = GeneralUtility::makeInstance(ResourceFactory::class)->retrieveFileOrFolderObject($value);
83+
return ($file) ? new FalFile($file) : null;
8384
}
8485
}
8586

‎Classes/Domain/Model/Image.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public static function fromString(string $value): ?self
5252
try {
5353
return new RemoteImage($value);
5454
} catch (InvalidRemoteImageException $e) {
55-
return new LocalImage($value);
55+
$file = GeneralUtility::makeInstance(ResourceFactory::class)->retrieveFileOrFolderObject($value);
56+
return ($file) ? new FalImage($file) : null;
5657
}
5758
}
5859

‎Classes/Domain/Model/LocalFile.php

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/**
1010
* Data structure for a local file resource to be passed to a component
11+
* @deprecated, use FalFile instead
1112
*/
1213
class LocalFile extends File
1314
{

‎Classes/Domain/Model/LocalImage.php

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/**
1010
* Data structure for a local image resource to be passed to a component
11+
* @deprecated, use FalImage instead
1112
*/
1213
class LocalImage extends Image
1314
{

‎Classes/Domain/Model/RemoteImage.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class RemoteImage extends Image
2727
* Creates an image object for a remote image resource
2828
*
2929
* @param string $uri
30-
* @throws InvalidFilePathException
30+
* @throws InvalidRemoteImageException
3131
*/
3232
public function __construct(string $uri)
3333
{

‎Classes/Exception/InvalidFilePathException.php

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace SMS\FluidComponents\Exception;
44

5+
/**
6+
* @deprecated, only used in deprecated LocalFile and LocalImage
7+
*/
58
class InvalidFilePathException extends \Exception
69
{
710
}

‎Documentation/DataStructures.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,15 @@ files from inside extensions or even external image urls. This is what the File/
110110
for images:
111111

112112
* `SMS\FluidComponents\Domain\Model\Image` (alias: `Image`) is the base class of all image types as well as a factory
113-
* `SMS\FluidComponents\Domain\Model\LocalImage` wraps a local image resource, e. g. from an extension
114113
* `SMS\FluidComponents\Domain\Model\RemoteImage` wraps a remote image uri
115-
* `SMS\FluidComponents\Domain\Model\FalImage` wraps existing FAL objects, such as `File` and `FileReference`
114+
* `SMS\FluidComponents\Domain\Model\FalImage` wraps existing FAL objects and local image resources, such as `File` and `FileReference` or an image from an extension
116115
* `SMS\FluidComponents\Domain\Model\PlaceholderImage` generates a placeholder image via placeholder.com
117116

118117
for files:
119118

120119
* `SMS\FluidComponents\Domain\Model\File` (alias: `File`) is the base class of all file types as well as a factory
121-
* `SMS\FluidComponents\Domain\Model\LocalFile` wraps a local file, e. g. from an extension
122120
* `SMS\FluidComponents\Domain\Model\RemoteFile` wraps a remote file uri
123-
* `SMS\FluidComponents\Domain\Model\FalFile` wraps existing FAL objects, such as `File` and `FileReference`
121+
* `SMS\FluidComponents\Domain\Model\FalFile` wraps existing FAL objects and local files, such as `File` and `FileReference` or a file from an extension
124122

125123
This is how it could look like in the `Atom.Image` component:
126124

0 commit comments

Comments
 (0)
Please sign in to comment.