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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Twig function to generate content URLs #6738

Merged
merged 10 commits into from Jan 26, 2024

Conversation

aschempp
Copy link
Member

First thing I found missing while using content URLs in my project 馃檭

@aschempp aschempp added this to the 5.3 milestone Jan 18, 2024
@aschempp aschempp requested review from m-vo and a team January 18, 2024 15:39
@aschempp aschempp self-assigned this Jan 18, 2024
fritzmg
fritzmg previously approved these changes Jan 18, 2024
Copy link
Member

@Toflar Toflar left a comment

Choose a reason for hiding this comment

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

This needs a try catch block 馃

bytehead
bytehead previously approved these changes Jan 18, 2024
Copy link
Member

@bytehead bytehead left a comment

Choose a reason for hiding this comment

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

Apart from failing CS 馃憤

@m-vo
Copy link
Member

m-vo commented Jan 18, 2024

Any reason this is a separate extension and not in our default ContaoExtension like the other stuff?

@aschempp
Copy link
Member Author

Any reason this is a separate extension and not in our default ContaoExtension like the other stuff?

I initially had it in there. But I don't know why everything is in one instead of split by topic? I feld like adding yet another constructor injection felt kinda bad style?

@m-vo
Copy link
Member

m-vo commented Jan 18, 2024

Why constructor injection? We're using runtimes for nearly everything which already separates stuff (and makes it lazy). The only reason for another extension would IMHO be if this will be put in another bundle or users could use it individually.

@ausi
Copy link
Member

ausi commented Jan 22, 2024

I agree with @m-vo here, the generate() method and the is_safe_callback should be in a new ContentUrlRuntime service and the TwigFunction should be registered in the ContaoExtension. Same as we did for all other Twig functions and filters.

@aschempp
Copy link
Member Author

You mean like this?

@ausi
Copy link
Member

ausi commented Jan 23, 2024

You mean like this?

Yes, perfect 鉂わ笍

@leofeyer leofeyer merged commit b6e9419 into contao:5.3 Jan 26, 2024
17 checks passed
@leofeyer
Copy link
Member

Thank you @aschempp.

@aschempp aschempp deleted the feature/twig-content-url branch January 29, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants