<?php
namespace App\EventListener;
use App\Event\ThemeChangedEvent;
class ThemeChangedListener
{
/**
* @var string
*/
private $environment;
/**
* ThemeChangedListener constructor.
*/
public function __construct(string $environment)
{
$this->environment = $environment;
}
public function themeChanged(ThemeChangedEvent $event): void
{
$env = 'prod' === $this->environment ? 'production' : 'dev';
exec(sprintf('yarn run encore %s --env.theme=%s ', $env, mb_strtolower($event->getNewTheme())));
}
}