private function addResource($path, PuliResource $resource)
{
$basePath = '/' === $path ? $path : $path . '/';
// Read children before attaching the resource to this repository
$children = $resource->listChildren();
$resource = clone $resource;
$resource->attachTo($this, $path);
// Add the resource before adding its children, so that the array
// stays sorted
$this->resources[$path] = $resource;
foreach ($children as $name => $child) {
$this->addResource($basePath . $name, $child);
}
$this->storeVersion($resource);
}