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

Update add-custom-page.md #1557

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions guides/plugins/plugins/storefront/add-custom-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

It has a method `examplePage`, which is accessible via the route `example-page`. This method will be responsible for loading your page later on, but we'll leave it like that for now.

Don't forget to [register your controller via the DI](add-custom-controller#Services.xml%20example).
Don't forget to [register your controller via the DI](add-custom-controller#services-xml-example).

### Creating the pageloader

Expand Down Expand Up @@ -162,6 +162,23 @@

Note, that we've added the page to the template variables.

#### Adjusting the services.xml

In addition, it is necessary to pass the argument with the ID of the `ExamplePageLoader` class to the [configuration ](add-custom-controller#services-xml-example) of the controller service in the `services.xml`.

```html

Check warning on line 169 in guides/plugins/plugins/storefront/add-custom-page.md

View workflow job for this annotation

GitHub Actions / Runner

[LanguageTool] reported by reviewdog 🐶 File types are normally capitalized. (FILE_EXTENSIONS_CASE[1]) Suggestions: `HTML` URL: https://languagetool.org/insights/post/spelling-capital-letters/ Rule: https://community.languagetool.org/rule/show/FILE_EXTENSIONS_CASE?lang=en-US&subId=1 Category: CASING Raw Output: guides/plugins/plugins/storefront/add-custom-page.md:169:3: File types are normally capitalized. (FILE_EXTENSIONS_CASE[1]) Suggestions: `HTML` URL: https://languagetool.org/insights/post/spelling-capital-letters/ Rule: https://community.languagetool.org/rule/show/FILE_EXTENSIONS_CASE?lang=en-US&subId=1 Category: CASING
jrson83 marked this conversation as resolved.
Show resolved Hide resolved
// <plugin root>/src/Resources/config/services.xml
<service id="Swag\BasicExample\Storefront\Controller\ExampleController" public="true">
<argument type="service" id="Swag\BasicExample\Storefront\Page\Example\ExamplePageLoader" />
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
<call method="setTwig">
<argument type="service" id="twig"/>
</call>
</service>
```

### Creating the example page

So now we're going to create the example page class, that was already used in our page loader, `ExamplePage`.
Expand Down Expand Up @@ -195,7 +212,7 @@
}
```

As explained in the page loader section, your page can contain all kinds of custom data. It has to provide a getter and a setter for the custom data, so it can be applied and read. In this example, the entity from our guide about [creating custom complex data](../framework/data-handling/add-custom-complex-data#Entity%20class) is being used.
As explained in the page loader section, your page can contain all kinds of custom data. It has to provide a getter and a setter for the custom data, so it can be applied and read. In this example, the entity from our guide about [creating custom complex data](../framework/data-handling/add-custom-complex-data#entity-class) is being used.

And that's it already. Your page is ready to go.

Expand Down
Loading