public function getVersions($path, ResourceRepository $repository = null)
{
if (!isset($this->versions[$path])) {
throw NoVersionFoundException::forPath($path);
}
$versions = array();
foreach ($this->versions[$path] as $resource) {
if (null !== $repository) {
$resource = clone $resource;
$resource->attachTo($repository, $path);
}
$versions[] = $resource;
}
return new VersionList($path, $versions);
}