Skip to content

Commit

Permalink
bug #129 doc: Update "Your first theme" documentation (pocky)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.4 branch.

Discussion
----------

Hello!

I am using SyliusThemeBundle on a new Monofony project and after reading documentation (because I always read documentation 👯 ) I seen some problems:

- First about `theme.json`, documentation is always talking about `composer.json` even if it's possible to have a `theme.json` and a `composer.json` (which is explained in docs/theme_configuration_reference.md)
- Second on the ThemeRequestListener which is not accurate for Symfony 5+. `GetResponseEvent` was deprecated in Symfony 4+ for `RequestEvent`

Thanks for reading and hope it will help!

Commits
-------

5c3824c doc: Update "Your first theme" documentation
  • Loading branch information
GSadee authored Jul 18, 2024
2 parents df263ac + 5c3824c commit 71bc3ab
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/your_first_theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ When adding or removing a theme, it's necessary to rebuild the container (same a

### Theme structure

Themes can override and add both bundle resources and app resources. When your theme configuration is in `SampleTheme/theme.json`,
Themes can override and add both bundle resources and app resources. When your theme configuration is in `SampleTheme/composer.json`,
app resources should be located at `SampleTheme/templates` for templates, `SampleTheme/translations` for translations and `SampleTheme/public` for assets.
To override a specific bundle's template (eg. `FOSUserBundle`), put it in `SampleTheme/templates/bundles/FOSUserBundle` directory.

Expand Down Expand Up @@ -65,9 +65,13 @@ Create an event listener and register it as listening for `kernel.request` event
```php
use Sylius\Bundle\ThemeBundle\Context\SettableThemeContext;
use Sylius\Bundle\ThemeBundle\Repository\ThemeRepositoryInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;

#[AsEventListener(
event: RequestEvent::class,
)]
final class ThemeRequestListener
{
/** @var ThemeRepositoryInterface */
Expand All @@ -82,7 +86,7 @@ final class ThemeRequestListener
$this->themeContext = $themeContext;
}

public function onKernelRequest(GetResponseEvent $event): void
public function onKernelRequest(RequestEvent $event): void
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
// don't do anything if it's not the master request
Expand Down

0 comments on commit 71bc3ab

Please sign in to comment.