45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KupShop\GraphQLBundle\Util;
|
|
|
|
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
|
use Symfony\Component\Cache\Psr16Cache;
|
|
use TheCodingMachine\GraphQLite\SchemaFactory;
|
|
|
|
class GraphQLFactory
|
|
{
|
|
public array $adminConfig = [];
|
|
|
|
public function setAdminConfig(array $adminConfig): void
|
|
{
|
|
$this->adminConfig = $adminConfig;
|
|
}
|
|
|
|
public function createSchemaFactory(array $controllerNamespaces, array $typeNamespaces): SchemaFactory
|
|
{
|
|
$cache = ServiceContainer::getService('cache.system');
|
|
|
|
$factory = new SchemaFactory(
|
|
new Psr16Cache($cache),
|
|
ServiceContainer::getContainer()
|
|
);
|
|
|
|
$this->addSchemaFactoryNamespaces($factory, $controllerNamespaces, $typeNamespaces);
|
|
|
|
return $factory;
|
|
}
|
|
|
|
public function addSchemaFactoryNamespaces(SchemaFactory $factory, array $controllerNamespaces, array $typeNamespaces): void
|
|
{
|
|
foreach ($controllerNamespaces as $controllerNamespace) {
|
|
$factory->addControllerNamespace($controllerNamespace);
|
|
}
|
|
|
|
foreach ($typeNamespaces as $typeNamespace) {
|
|
$factory->addTypeNamespace($typeNamespace);
|
|
}
|
|
}
|
|
}
|