<?php declare(strict_types=1);
namespace Swag\BasicExample\Storefront\Pagelet\Example;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Storefront\Page\GenericPageLoaderInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
class ExamplePageletLoader
private EventDispatcherInterface $eventDispatcher;
public function __construct(EventDispatcherInterface $eventDispatcher)
$this->eventDispatcher = $eventDispatcher;
public function load(Request $request, SalesChannelContext $context): ExamplePagelet
$pagelet = new ExamplePagelet();
// Do additional stuff, e.g. load more data from repositories and add it to page
$pagelet->setExampleData(...);
$this->eventDispatcher->dispatch(
new ExamplePageletLoadedEvent($pagelet, $context, $request)