Merge pull request #209 from php-flasher/issues/208

feat: make mainScript nullable
This commit is contained in:
Younes ENNAJI
2025-01-18 11:22:59 +01:00
committed by GitHub
@@ -27,14 +27,16 @@ final readonly class ResourceManager implements ResourceManagerInterface
public function __construct( public function __construct(
private TemplateEngineInterface $templateEngine, private TemplateEngineInterface $templateEngine,
private AssetManagerInterface $assetManager, private AssetManagerInterface $assetManager,
private string $mainScript, private ?string $mainScript = null,
private array $resources, private array $resources = [],
) { ) {
} }
public function populateResponse(Response $response): Response public function populateResponse(Response $response): Response
{ {
$response->setMainScript($this->assetManager->getPath($this->mainScript)); if (null !== $this->mainScript) {
$response->setMainScript($this->assetManager->getPath($this->mainScript));
}
$plugins = []; $plugins = [];
foreach ($response->getEnvelopes() as $envelope) { foreach ($response->getEnvelopes() as $envelope) {