public function findById($id)
{
if (!file_exists($path = $this->getPathForDocument($id))) {
return false;
}
$fp = fopen($path, 'r');
$contents = fread($fp, filesize($path));
fclose($fp);
$data = $this->formatter->decode($contents);
if ($data === null) {
return false;
}
$ext = $this->formatter->getFileExtension();
$doc = new $this->documentClass((array) $data);
$doc->setId($this->getIdFromPath($path, $ext));
return $doc;
}