Download the PHP package bukashk0zzz/liip-imagine-serialization-bundle without Composer
On this page you can find all versions of the php package bukashk0zzz/liip-imagine-serialization-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bukashk0zzz/liip-imagine-serialization-bundle
More information about bukashk0zzz/liip-imagine-serialization-bundle
Files in bukashk0zzz/liip-imagine-serialization-bundle
Package liip-imagine-serialization-bundle
Short Description Provides integration between LiipImagineBundle and JMSSerializerBundle.
License MIT
Homepage https://github.com/bukashk0zzz/LiipImagineSerializationBundle
Informations about the package liip-imagine-serialization-bundle
Symfony LiipImagineSerialization Bundle
About
Provides integration between LiipImagineBundle and
JMSSerializerBundle.
Allows to generate full or relative URIs to entity fields mapped with @Bukashk0zzz
and @JMS
annotations during the serialization.
Also bundle supports VichUploaderBundle field type.
Installation Symfony Flex
Installation without Symfony Flex
Add the bundle to app/AppKernel.php
Configuration
Add this to your config.yml
:
Usage
Add the next class to the use
section of your entity class.
Bundle provides two annotations which allow the serialization of url or @Vich\UploadableField
fields in your entities.
At first you have to add @Bukashk0zzz\LiipImagineSerializableClass
to the entity class which has image fields.
Then you have to add @Bukashk0zzz\LiipImagineSerializableField
annotation to the field you want to serialize.
Annotation @Bukashk0zzz\LiipImagineSerializableClass
does not have any option.
Annotation @Bukashk0zzz\LiipImagineSerializableField
has one required option filter which value should link to the LiipImagine filter.
It can be set like this @Bukashk0zzz\LiipImagineSerializableField("photoFile")
or @Bukashk0zzz\LiipImagineSerializableField(filter="photoFile")
.
filter can be array of filters in this case serialized field will be also array.
For example if you add annotation @Bukashk0zzz\LiipImagineSerializableField(filter={"big", "small"})
for field image
then you get:
Also there is another two options:
vichUploaderField
- If you use VichUploaderBundle for your uploads you must specify link to the field with@Vich\UploadableField
annotationvirtualField
- By default serializer will override field value with link to filtered image. If you addvirtualField
option serializer will add to serialized object new field with name that you provided in this option and url to filtered image, original field in this case will be unattached. This option are required if you're using an array of filters.
Don't forget that to serialize image fields they also should be marked with @JMS
annotations to be serialized.
The generated URI by default:
The generated URI with includeHost
set to false
:
If you need to change url before passing it to LiipImagine, for example you need to swap origin name, you can use originUrlNormalizer option in bundle config.
If you need to change url after LiipImagine processing, for example you need to swap origin domain, you can use filteredUrlNormalizer option in bundle config.
UrlNormalizer class must implement UrlNormalizerInterface
Events
There are two events:
- bukashk0zzz_liip_imagine.event_pre_origin_normalize // Dispatch before origin url normalization
- bukashk0zzz_liip_imagine.event_pre_filtered_normalize // Dispatch before filtered url normalization
Example subscriber:
Example
Copyright / License
See LICENSE
All versions of liip-imagine-serialization-bundle with dependencies
symfony/dependency-injection Version ^4.0|^5.0
symfony/yaml Version ^4.0|^5.0
doctrine/orm Version ^2.5
jms/serializer-bundle Version ^3.0|^4.0
liip/imagine-bundle Version ^1.8|^2.3
vich/uploader-bundle Version ^1.5