Skip to content

Commit 0f69516

Browse files
committed
Add an EntrypointLookupCollection.
This collection will be used to store all the different builds EntrypointLookup instances.
1 parent ebe61d9 commit 0f69516

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony WebpackEncoreBundle package.
5+
* (c) Fabien Potencier <[email protected]>
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
namespace Symfony\WebpackEncoreBundle\Asset;
11+
12+
use Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException;
13+
use Psr\Container\ContainerInterface;
14+
15+
/**
16+
* Aggregate the different entry points configured in the container.
17+
*
18+
* Retrieve the EntrypointLookup instance from the given key.
19+
*
20+
* @final
21+
*/
22+
class EntrypointLookupCollection
23+
{
24+
private $buildEntrypoints;
25+
26+
public function __construct(ContainerInterface $buildEntrypoints)
27+
{
28+
$this->buildEntrypoints = $buildEntrypoints;
29+
}
30+
31+
public function getEntrypointLookup(string $buildName): EntrypointLookupInterface
32+
{
33+
if (!$this->buildEntrypoints->has($buildName)) {
34+
throw new UndefinedBuildException(sprintf('Given entry point "%s" is not configured', $buildName));
35+
}
36+
37+
return $this->buildEntrypoints->get($buildName);
38+
}
39+
}

0 commit comments

Comments
 (0)