public function add($path, $resource)
{
if (null === $this->json) {
$this->load();
}
$path = $this->sanitizePath($path);
if ($resource instanceof ResourceCollection) {
$this->ensureDirectoryExists($path);
foreach ($resource as $child) {
$this->addResource($path . '/' . $child->getName(), $child);
}
$this->flush();
return;
}
$this->ensureDirectoryExists(Path::getDirectory($path));
$this->addResource($path, $resource);
$this->flush();
}