/**
* {@inheritdoc}
*
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \LogicException
* @throws BadMethodCallException
*/
public function load($resource, $type = null)
{
$path = $this->locator->locate($resource);
$this->container->addResource(new FileResource($path));
$file = new JsonFile($path);
$content = $file->read();
$extension = pathinfo($resource, PATHINFO_FILENAME);
if (array_key_exists('parameters', $content)) {
foreach ($content['parameters'] as $name => $parameter) {
$this->container->setParameter($name, $parameter);
}
unset($content['parameters']);
}
if (array_key_exists('imports', $content)) {
foreach ($content['imports'] as $import) {
$importFilename = $import;
if (!Path::isAbsolute($importFilename)) {
$importFilename = Path::join([dirname($path), $import]);
}
$this->import($importFilename, null, false, $file);
}
unset($content['imports']);
}
$this->container->loadFromExtension($extension, $content);
}