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.<plugin root>/src/Storefront/Page/Example
.ExamplePageLoader.php
. It's a new service, which doesn't have to extend from any other class. You might want to implement a ExamplePageLoaderInterface
interface, which is not explained in this guide. You can do that in order to have a decoratable page loader class.ExamplePage
, will be created in the next section), filling it with data, e.g. from repositories, and firing a PageLoaded
event, so others can react to your page being loaded.ExamplePageLoader
:GenericPageLoaderInterface
and the EventDispatcherInterface
.EventDispatcherInterface
is of course necessary in order to fire an event later on.load
method, which is not mandatory, but convention. You want your page loader to work like all the other page loaders, right? It should return an instance of your example page, in this case ExamplePage
. Don't worry, we haven't created that one yet, it will be created in the next sections. So, the first thing it does is basically creating a Page
instance, containing all necessary basic data, such as the footer etc.createFrom
. This method is available, since your ExamplePage
has to extend from the Page
struct, which in return extends from the Struct
class. The latter implements the CreateFromTrait containing this method. In short, this will create an instance of your ExamplePage
, containing all the data from the generic Page
object.ExamplePageLoadedEvent
.load
method.ExamplePage
.Shopware\Storefront\Page\Page
class in order to contain a field for the header, the footer etc., as well as some helper methods.Shopware\Storefront\Page\PageLoadedEvent
class.ExamplePage
, which it has to save into a property and there needs to be a getter in order to get the example page instance. Additional constructor parameters are the Request
and the SalesChannelContext
, which you have to pass to the parent's constructor.ExamplePageLoadedEvent
class.load
method, you've used the GenericPageLoader
, which takes care of such a thing as the footer or the header. Those two are so called "pagelets", basically reusable fractions of a page. Learn how to create a custom pagelet yourself here.