-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListFactory.php
32 lines (25 loc) · 1.05 KB
/
ListFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace Jeandanyel\ListBundle\Factory;
use Jeandanyel\ListBundle\Builder\ListBuilderInterface;
use Jeandanyel\ListBundle\List\ListInterface;
use Jeandanyel\ListBundle\Mapper\RequestHandlerMapper;
use Jeandanyel\ListBundle\Registry\ListRegistryInterface;
class ListFactory implements ListFactoryInterface
{
public function __construct(
private ListRegistryInterface $listRegistry,
private ColumnFactoryInterface $columnFactory,
private RequestHandlerMapper $requestHandlerMapper,
) {}
public function create(string $listTypeClass, array $options = []): ListInterface
{
return $this->createBuilder($listTypeClass, $options)->getList();
}
public function createBuilder(string $listTypeClass, array $options = []): ListBuilderInterface
{
$listType = $this->listRegistry->getType($listTypeClass);
$builder = $listType->createBuilder($this->columnFactory, $this->requestHandlerMapper, $options);
$listType->buildList($builder, $builder->getOptions());
return $builder;
}
}