diff --git a/Classes/Domain/Model/Image.php b/Classes/Domain/Model/Image.php index 92c968e..b217fed 100644 --- a/Classes/Domain/Model/Image.php +++ b/Classes/Domain/Model/Image.php @@ -82,6 +82,9 @@ public static function fromInteger(int $value): self * Creates an image object based on data passed by array. There are numerous * array structures that create a valid image object: * + * FAL file object: + * [ "fileObject" => $myFileObject ] + * * FAL file uid: * * [ "fileUid" => 123 ] @@ -141,8 +144,11 @@ public static function fromInteger(int $value): self */ public static function fromArray(array $value): self { + // Create an imafe from an existing FAL object + if (isset($value['fileObject'])) { + $image = static::fromFileInterface($value['fileObject']); // Create an image from file uid - if (isset($value['fileUid'])) { + } elseif (isset($value['fileUid'])) { $image = static::fromFileUid((int) $value['fileUid']); // Create an image from file reference uid } elseif (isset($value['fileReferenceUid'])) { diff --git a/Documentation/DataStructures.md b/Documentation/DataStructures.md new file mode 100644 index 0000000..3870e8d --- /dev/null +++ b/Documentation/DataStructures.md @@ -0,0 +1,205 @@ +# Fluid Components: Data Structures + +One key aspect of components is the clearly defined interface between the integration +and the the component renderer via parameters. By default, Fluid +and Fluid Components support scalar data types, such as `string` or `integer`, and the +compound type `array` for arguments. But it is also possible to pass PHP objects to +ViewHelpers or components. + +This allows us to define complex data structures which make the component interface +more formal but also more flexible during integration. + +## Links and TypoLink + +`SMS\FluidComponents\Domain\Model\Link` +`SMS\FluidComponents\Domain\Model\TypoLink` + +TYPO3's backend link wizards generate a link definition in the so-called Typolink format: + +``` +t3://page?uid=123 _blank myCssClass "Title of the link" +``` + +It contains the link itself, but also allows you to specify a target, a link title, and additional css classes. + +When a component takes a link as one of its parameters, it should on the one hand be able +to use a Typolink, but on the other hand it should be able to use a simple HTTP url. This +is where the TypoLink datastructure as well as argument converters come into play: + +Our sample component `Atom.Link`: + +```xml + + + + + + + {label} + + + +``` + +This component can be called in the following ways thanks to the implicit conversion +Fluid Components offers: + +```xml + + + + + + + + + + + + + +``` + +In addition to the TypoLink parsing, the Link data structure also gives access to the individual parts +of the URI by using `parse_url`. You get access to the following link properties in the component renderer: + +* `originalLink`: TYPO3 link data structure, e. g. `['type' => 'page', 'pageuid' => 1]` +* `target`: e. g. `_blank` +* `class`: additional CSS classes that should be set on the `` tag +* `title`: title attribute of the `` tag +* `uri`: complete url, e. g. `https://myuser:mypassword@www.example.com:8080/my/path/file.jpg?myparam=1#myfragment` +* `scheme`: e. g. `https` +* `host`: e. g. `www.example.com` +* `port`: e. g. `8080` +* `user`: e. g. `myuser` +* `pass`: e. g. `mypassword` +* `path`: e. g. `/my/path/file.jpg` +* `query`: e. g. `myparam=1` +* `fragment`: e. g. `myfragment` + +## Images + +Components should be able to accept an image as a parameter, no matter where it come from. TYPO3 already has data structures +for images that are stored in the File Abstraction Layer. However, there are cases where you want to use +images from inside extensions or even external image urls. This is what the Image data structures offer: + +* `SMS\FluidComponents\Domain\Model\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\PlaceholderImage` generates a placeholder image via placeholder.com + +This is how it could look like in the `Atom.Image` component: + +```xml + + + + + + + + + + + + {image.alternative} + + + + +``` + +And these are the different options to call that component: + +```xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +Inside the component renderer, you get access to the following image properties, +no matter which image variant is used: + +* `type`: name of the image implementation, e. g. `PlaceholderImage` +* `publicUrl`: url that can be used in an ` - + light @@ -141,6 +141,7 @@ the [ViewHelper Reference](Documentation/ViewHelperReference.md). ## Extended Documentation * [ViewHelper Reference](Documentation/ViewHelperReference.md) +* [Included Data Structures](Documentation/DataStructures.md) * [Component Prefixers](Documentation/ComponentPrefixers.md) * [Component Settings](Documentation/ComponentSettings.md) * [Usage with Forms](Documentation/Forms.md) diff --git a/ext_emconf.php b/ext_emconf.php index ace6eb9..548c636 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -9,7 +9,7 @@ 'state' => 'beta', 'uploadfolder' => false, 'clearCacheOnLoad' => false, - 'version' => '1.1.2', + 'version' => '1.2.0', 'constraints' => [ 'depends' => [ 'typo3' => '8.7.0-9.9.99',