Esempio n. 1
0
 /**
  * Method to serialise an EasyRdf\Graph to RDF/JSON
  *
  * http://n2.talis.com/wiki/RDF_JSON_Specification
  * docs/appendix-a-rdf-formats-json.md
  *
  * @param Graph  $graph   An EasyRdf\Graph object.
  * @param string $format  The name of the format to convert to.
  * @param array  $options
  *
  * @throws Exception
  *
  * @return string The RDF in the new desired format.
  */
 public function serialise($graph, $format, array $options = array())
 {
     parent::checkSerialiseParams($graph, $format);
     if ($format != 'json') {
         throw new Exception("EasyRdf\\Serialiser\\Json does not support: {$format}");
     }
     return json_encode(parent::serialise($graph, 'php'));
 }
Esempio n. 2
0
 /**
  * Serialise an EasyRdf\Graph into RDF format of choice.
  *
  * @param Graph  $graph   An EasyRdf\Graph object.
  * @param string $format  The name of the format to convert to.
  * @param array  $options
  *
  * @throws Exception
  *
  * @return string              The RDF in the new desired format.
  */
 public function serialise($graph, $format, array $options = array())
 {
     parent::checkSerialiseParams($graph, $format);
     if (array_key_exists($format, self::$supportedTypes)) {
         $className = self::$supportedTypes[$format];
     } else {
         throw new Exception("EasyRdf\\Serialiser\\Arc does not support: {$format}");
     }
     $serialiser = \ARC2::getSer($className);
     if ($serialiser) {
         return $serialiser->getSerializedIndex(parent::serialise($graph, 'php'));
     } else {
         throw new Exception("ARC2 failed to get a {$className} serialiser.");
     }
 }