Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Deprecate LocalFile/LocalImage, use Fal instead #128

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
1 change: 1 addition & 0 deletions Classes/Domain/Model/LocalFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/**
* Data structure for a local file resource to be passed to a component
* @deprecated, use FalFile instead
*/
class LocalFile extends File
{
Expand Down
1 change: 1 addition & 0 deletions Classes/Domain/Model/LocalImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/**
* Data structure for a local image resource to be passed to a component
* @deprecated, use FalImage instead
*/
class LocalImage extends Image
{
Expand Down
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
3 changes: 3 additions & 0 deletions Classes/Exception/InvalidFilePathException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace SMS\FluidComponents\Exception;

/**
* @deprecated, only used in deprecated LocalFile and LocalImage
*/
class InvalidFilePathException extends \Exception
{
}
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