--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/server/src/app/Models/WebResourceManager.php Thu Jun 02 18:24:19 2016 +0200
@@ -0,0 +1,35 @@
+<?php
+namespace CorpusParole\Models;
+
+use EasyRdf\Resource;
+
+/**
+ */
+class WebResourceManager {
+
+ public static function getResource(...$args) {
+
+ list($url,$graph) = $args;
+ $webResource = new Resource($url, $graph);
+ $formatLit = $webResource->getLiteral("dc11:format");
+ $format = is_null($formatLit)?null:$formatLit->getValue();
+ if(is_null($format)) {
+ throw new ModelsException("WebResourceManager: No dc:11 format on web resource");
+ }
+
+ if(0 === strpos($format, 'audio/') ||
+ 0 === strpos($format, 'video/') ||
+ 0 === strpos($format, 'Sampling:') ) {
+ return new MediaResource(...$args);
+ } else if(
+ 0 === strpos($format, 'application/xml') ||
+ 0 === strpos($format, 'application/pdf') ) {
+ return new TranscriptResource(...$args);
+ }
+ else {
+ throw new ModelsException("WebResourceManager: unknown format");
+ }
+
+ }
+
+}
\ No newline at end of file