Skip to content

Conversation

@andrehoffmann30
Copy link

@andrehoffmann30 andrehoffmann30 commented Oct 27, 2025

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.

@andrehoffmann30 andrehoffmann30 marked this pull request as ready for review October 28, 2025 14:49
@jacquesbh jacquesbh requested a review from Copilot November 3, 2025 18:05
@madamebiz madamebiz added the Status: needs review Status: needs review label Nov 3, 2025
Copy link

Copilot AI left a 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 PageLink Twig 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();
Copy link

Copilot AI Nov 3, 2025

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.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,3 @@
{% if href and page_title %}
<a href="{{href}}" {{ attributes }}>{{page_title}}</a>
Copy link

Copilot AI Nov 3, 2025

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.

Suggested change
<a href="{{href}}" {{ attributes }}>{{page_title}}</a>
<a href="{{ href }}" {{ attributes }}>{{ page_title }}</a>

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: needs review Status: needs review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants