-
Notifications
You must be signed in to change notification settings - Fork 29
FEATURE: add twig component to render link to cms page #91
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
base: 2.x
Are you sure you want to change the base?
FEATURE: add twig component to render link to cms page #91
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a Twig component to render links to CMS pages by their page code, enabling easy linking to CMS pages from any template or hook in a Sylius shop.
Key changes:
- Introduces a new
PageLinkTwig component that accepts a page code and generates a link with title - Adds repository method to find pages by code instead of slug
- Updates component configuration and documentation
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Twig/Component/PageLink.php | New Twig component class that generates page links and titles from page codes |
| src/Resources/views/twig/components/PageLink.html.twig | Twig template for rendering the page link component |
| src/Repository/PageRepositoryInterface.php | Adds method signature for finding pages by code and channel |
| src/Repository/PageRepository.php | Implements the new repository method to find pages by code |
| src/DependencyInjection/MonsieurBizSyliusCmsPageExtension.php | Registers the new Twig component namespace and template directory |
| README.md | Documents usage of the new PageLink component |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| $currentLocaleCode = $this->localeContext->getLocaleCode(); | ||
| $channel = $this->channelContext->getChannel(); | ||
| $now = new \DateTime(); |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new DateTime object on every call can cause inconsistent results if the method is called multiple times during the same request. Consider injecting a clock service or creating the DateTime once and storing it as a property.
| @@ -0,0 +1,3 @@ | |||
| {% if href and page_title %} | |||
| <a href="{{href}}" {{ attributes }}>{{page_title}}</a> | |||
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Missing spaces around Twig variables. Should be {{ href }} and {{ page_title }} for consistency with Twig formatting standards.
| <a href="{{href}}" {{ attributes }}>{{page_title}}</a> | |
| <a href="{{ href }}" {{ attributes }}>{{ page_title }}</a> |
Add a twig component to render a link to a cms page for a give page code. Now one can add a link to a cms page in any template or hook for example for the header or footer of a sylius shop.