/**
  * Transform a resource to an elastica document.
  *
  * @param $uri
  * @param $index
  * @param $type
  *
  * @return Document|null
  */
 public function transform($uri, $index, $type)
 {
     if ($index && $this->serializerHelper->isTypeIndexed($index, $type)) {
         $frame = $this->serializerHelper->getTypeFramePath($index, $type);
         $phpClass = TypeMapper::get($type);
         if (!$phpClass) {
             $phpClass = "EasyRdf\\Resource";
         }
         $jsonLd = $this->jsonLdSerializer->serialize(new $phpClass($uri), $frame, array("includeParentClassFrame" => true));
         $graph = json_decode($jsonLd, true);
         if (!isset($graph['@graph'][0])) {
             return;
         }
         $resource = $graph['@graph'][0];
         $resource['@id'] = $uri;
         $json = json_encode($resource);
         $json = str_replace('@id', '_id', $json);
         $json = str_replace('@type', '_type', $json);
         $index = $this->configManager->getIndexConfiguration($index)->getElasticSearchName();
         return new Document($uri, $json, $type, $index);
     }
     return;
 }