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

NGSTACK-901 implement decorator service for variation path generator #51

Open
wants to merge 3 commits into
base: 1.7
Choose a base branch
from

Conversation

hknezevic
Copy link
Member

Implement decorator service for variation path generator which will replace file extension with webp, if image variation is configured for this format.

The implementation is heavily based on ezsystems/ezplatform-kernel#361, except we don't just append ".webp" on full generated image path, but instead replace the generated file extension with 'webp'.

The reason for this is keeping backward compatibility with eZ Publish legacy kernel (used in Netgen Admin UI). Legacy image aliases can be configured to be generated in specific format/mime type (i.e. original image is JPG but variation will be generated as WebP). But in this case, the alias filenames will always contain only one file extension, the one specified by the alias mime type. So this should prevent duplicate images being generated on the file system, both legacy and Symfony variation generators will use same alias path patterns.

This decorator serves purpose only for the ezsystems/ezpublish-kernel with or without the legacy-based admin.
Later kernel versions (both ezplatform-kernel and ibexa) already contain this decorator service by default.

… which will replace file extension with webp if image variation is configured for this format
Copy link
Member

@pspanja pspanja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@iherak
Copy link
Member

iherak commented Jun 25, 2024

Except for the CS style nitpicks, LGTM 👍

use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

class WebpFormatVariationPathGeneratorDecoratorPass implements CompilerPassInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need the compiler pass just to register a decorator?

Can't we do this through the service config in YAML files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Half of my life you force me to write compiler passes, now you want me to add it in the config 😆
I wasn't initially sure if we want to make the decorator service enabled by default, or if we will need to introduce a switch through configuration. @vjeran wants this enabled by default in both legacy admin and symfony/ezplatform, so maybe no need for the compiler pass.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler passes should be used when modifying eixsting services! With this, we're not modifying an existing service, but adding a new one.

Besides, we're already using decorators directly in yaml files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it like this for consistency sake, as we will be using the compiler pass to actually decorate the existing variation path generator in Ibexa 4.x with our own service. If we are using 4.x in combination with legacy admin, then this is needed to consolidate variation path patterns to match the ones from legacy. The compiler pass in that case will replace ibexa decorator class with our own.

@emodric
Copy link
Member

emodric commented Jun 25, 2024

I presume this does not need to be merged into master ?

@hknezevic
Copy link
Member Author

hknezevic commented Jun 28, 2024

@emodric no, this works only for ezplatform + ngadminui combination, so only applies to 1.7 branch
For the Ibexa + ngadminui, we will need to use this decorator implementation to override default Ibexa decorator service, as it just concatenates '.webp' suffix to the variation path instead of replacing original extension, and that is not compatible with the variation paths generated in legacy kernel.

Technically, we might merge this into master if I check the installed bundles, and make a separate logic in the compiler pass depending whether we have ibexa/core or ezpublish/kernel installed

@emodric
Copy link
Member

emodric commented Jun 28, 2024

Technically, we might merge this into master if I check the installed bundles, and make a separate logic in the compiler pass depending whether we have ibexa/core or ezpublish/kernel installed

Okay, I'll leave it as is for now and not merge to master (or rather, create an empty merge), and we'll fix that one when we get there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants