equal
deleted
inserted
replaced
|
1 <?php |
|
2 namespace CorpusParole\Models; |
|
3 |
|
4 use EasyRdf\Resource; |
|
5 |
|
6 /** |
|
7 */ |
|
8 class WebResourceManager { |
|
9 |
|
10 public static function getResource(...$args) { |
|
11 |
|
12 list($url,$graph) = $args; |
|
13 $webResource = new Resource($url, $graph); |
|
14 $formatLit = $webResource->getLiteral("dc11:format"); |
|
15 $format = is_null($formatLit)?null:$formatLit->getValue(); |
|
16 if(is_null($format)) { |
|
17 throw new ModelsException("WebResourceManager: No dc:11 format on web resource"); |
|
18 } |
|
19 |
|
20 if(0 === strpos($format, 'audio/') || |
|
21 0 === strpos($format, 'video/') || |
|
22 0 === strpos($format, 'Sampling:') ) { |
|
23 return new MediaResource(...$args); |
|
24 } else if( |
|
25 0 === strpos($format, 'application/xml') || |
|
26 0 === strpos($format, 'application/pdf') ) { |
|
27 return new TranscriptResource(...$args); |
|
28 } |
|
29 else { |
|
30 throw new ModelsException("WebResourceManager: unknown format"); |
|
31 } |
|
32 |
|
33 } |
|
34 |
|
35 } |