if (!
str_starts_with($namespace, 'Symfony\\Config\\'
)) { throw new InvalidArgumentException(sprintf('Could not find or generate class "%s".',
$namespace));
} // Try to get the extension alias
$alias = Container::
underscore(substr($namespace, 15, -6
));
if (str_contains($alias, '\\'
)) { throw new InvalidArgumentException('You can only use "root" ConfigBuilders from "Symfony\\Config\\" namespace. Nested classes like "Symfony\\Config\\Framework\\CacheConfig" cannot be used.'
);
} if (!
$this->container->
hasExtension($alias)) { $extensions =
array_filter(array_map(fn (ExtensionInterface
$ext) =>
$ext->
getAlias(),
$this->container->
getExtensions()));
throw new InvalidArgumentException(sprintf('There is no extension able to load the configuration for "%s". Looked for namespace "%s", found "%s".',
$namespace,
$alias,
$extensions ?
implode('", "',
$extensions) : 'none'
));
} $extension =
$this->container->
getExtension($alias);
if (!
$extension instanceof ConfigurationExtensionInterface
) { throw new \
LogicException(sprintf('You cannot use the config builder for "%s" because the extension does not implement "%s".',
$namespace, ConfigurationExtensionInterface::
class));
} $configuration =
$extension->
getConfiguration([],
$this->container
);
$loader =
$this->generator->
build($configuration);