Skip to content

Commit

Permalink
[FEATURE] Remove LocalFile/LocalImage, use Fal instead
Browse files Browse the repository at this point in the history
  • Loading branch information
s2b committed Jun 8, 2023
1 parent b0284b1 commit 5f76541
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 144 deletions.
3 changes: 2 additions & 1 deletion Classes/Domain/Model/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public static function fromString(string $value): ?self
try {
return new RemoteFile($value);
} catch (InvalidRemoteFileException $e) {
return new LocalFile($value);
$file = GeneralUtility::makeInstance(ResourceFactory::class)->retrieveFileOrFolderObject($value);
return ($file) ? new FalFile($file) : null;
}
}

Expand Down
3 changes: 2 additions & 1 deletion Classes/Domain/Model/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public static function fromString(string $value): ?self
try {
return new RemoteImage($value);
} catch (InvalidRemoteImageException $e) {
return new LocalImage($value);
$file = GeneralUtility::makeInstance(ResourceFactory::class)->retrieveFileOrFolderObject($value);
return ($file) ? new FalImage($file) : null;
}
}

Expand Down
65 changes: 0 additions & 65 deletions Classes/Domain/Model/LocalFile.php

This file was deleted.

65 changes: 0 additions & 65 deletions Classes/Domain/Model/LocalImage.php

This file was deleted.

2 changes: 1 addition & 1 deletion Classes/Domain/Model/RemoteImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RemoteImage extends Image
* Creates an image object for a remote image resource
*
* @param string $uri
* @throws InvalidFilePathException
* @throws InvalidRemoteImageException
*/
public function __construct(string $uri)
{
Expand Down
7 changes: 0 additions & 7 deletions Classes/Exception/InvalidFilePathException.php

This file was deleted.

6 changes: 2 additions & 4 deletions Documentation/DataStructures.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,15 @@ files from inside extensions or even external image urls. This is what the File/
for images:

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

for files:

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

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

Expand Down

0 comments on commit 5f76541

Please sign in to comment.