Completed
Pull Request — master (#877)
by
unknown
02:08
created
controller/RestController.php 3 patches
Doc Comments   +35 added lines patch added patch discarded remove patch
@@ -97,6 +97,9 @@  discard block
 block discarded – undo
97 97
         return $this->returnJson($ret);
98 98
     }
99 99
 
100
+    /**
101
+     * @param Request $request
102
+     */
100 103
     private function constructSearchParameters($request)
101 104
     {
102 105
         $parameters = new ConceptSearchParameters($request, $this->model->getConfig(), true);
@@ -112,6 +115,10 @@  discard block
 block discarded – undo
112 115
         return $parameters;
113 116
     }
114 117
 
118
+    /**
119
+     * @param Request $request
120
+     * @param ConceptSearchParameters $parameters
121
+     */
115 122
     private function transformSearchResults($request, $results, $parameters)
116 123
     {
117 124
         // before serializing to JSON, get rid of the Vocabulary object that came with each resource
@@ -407,6 +414,10 @@  discard block
 block discarded – undo
407 414
         return $this->returnJson($ret);
408 415
     }
409 416
 
417
+    /**
418
+     * @param string $label
419
+     * @param string $lang
420
+     */
410 421
     private function findLookupHits($results, $label, $lang)
411 422
     {
412 423
         $hits = array();
@@ -468,6 +479,9 @@  discard block
 block discarded – undo
468 479
         return $hits;
469 480
     }
470 481
 
482
+    /**
483
+     * @param string $lang
484
+     */
471 485
     private function transformLookupResults($lang, $hits)
472 486
     {
473 487
         if (sizeof($hits) == 0) {
@@ -539,6 +553,9 @@  discard block
 block discarded – undo
539 553
         return $this->returnJson($ret);
540 554
     }
541 555
 
556
+    /**
557
+     * @param Request $request
558
+     */
542 559
     private function redirectToVocabData($request) {
543 560
         $urls = $request->getVocab()->getConfig()->getDataURLs();
544 561
         if (sizeof($urls) == 0) {
@@ -564,6 +581,10 @@  discard block
 block discarded – undo
564 581
 		}
565 582
     }
566 583
 
584
+    /**
585
+     * @param string $results
586
+     * @param string $format
587
+     */
567 588
     private function returnDataResults($results, $format) {
568 589
         if ($format == 'application/ld+json' || $format == 'application/json') {
569 590
             // further compact JSON-LD document using a context
@@ -693,6 +714,12 @@  discard block
 block discarded – undo
693 714
         return $this->returnJson($ret);
694 715
     }
695 716
 
717
+    /**
718
+     * @param string $uri
719
+     * @param string $lang
720
+     * @param string $propname
721
+     * @param string $propuri
722
+     */
696 723
     private function transformPropertyResults($uri, $lang, $objects, $propname, $propuri)
697 724
     {
698 725
         $results = array();
@@ -708,6 +735,14 @@  discard block
 block discarded – undo
708 735
         return $ret;
709 736
     }
710 737
 
738
+    /**
739
+     * @param string $uri
740
+     * @param string $lang
741
+     * @param string $tpropname
742
+     * @param string $tpropuri
743
+     * @param string $dpropname
744
+     * @param string $dpropuri
745
+     */
711 746
     private function transformTransitivePropertyResults($uri, $lang, $objects, $tpropname, $tpropuri, $dpropname, $dpropuri)
712 747
     {
713 748
         $results = array();
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -550,18 +550,18 @@
 block discarded – undo
550 550
         if (!$format) {
551 551
             return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . implode(' ', array_keys($urls)));
552 552
         }
553
-		if (is_array($urls[$format])) {
554
-			$arr = $urls[$format];
555
-			$dataLang = $request->getLang();
556
-			if (isset($arr[$dataLang])) {
553
+    if (is_array($urls[$format])) {
554
+      $arr = $urls[$format];
555
+      $dataLang = $request->getLang();
556
+      if (isset($arr[$dataLang])) {
557 557
                 header("Location: " . $arr[$dataLang]);
558
-			} else {
559
-				$vocid = $request->getVocab()->getId();
560
-				return $this->returnError('404', 'Not Found', "No download source URL known for vocabulary $vocid in language $dataLang");
561
-			}
562
-		} else {
558
+      } else {
559
+        $vocid = $request->getVocab()->getId();
560
+        return $this->returnError('404', 'Not Found', "No download source URL known for vocabulary $vocid in language $dataLang");
561
+      }
562
+    } else {
563 563
             header("Location: " . $urls[$format]);
564
-		}
564
+    }
565 565
     }
566 566
 
567 567
     private function returnDataResults($results, $format) {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
         // wrap with JSONP callback if requested
26 26
         if (filter_input(INPUT_GET, 'callback', FILTER_SANITIZE_STRING)) {
27 27
             header("Content-type: application/javascript; charset=utf-8");
28
-            echo filter_input(INPUT_GET, 'callback', FILTER_UNSAFE_RAW) . "(" . json_encode($data) . ");";
28
+            echo filter_input(INPUT_GET, 'callback', FILTER_UNSAFE_RAW)."(".json_encode($data).");";
29 29
             return;
30 30
         }
31 31
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                 'vocabularies' => 'onki:hasVocabulary',
89 89
                 'id' => 'onki:vocabularyIdentifier',
90 90
                 'uri' => '@id',
91
-                '@base' => $this->getBaseHref() . "rest/v1/vocabularies",
91
+                '@base' => $this->getBaseHref()."rest/v1/vocabularies",
92 92
             ),
93 93
             'uri' => '',
94 94
             'vocabularies' => $results,
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         // convert to vocids array to support multi-vocabulary search
106 106
         $vocids = ($vocabs !== null && $vocabs !== '') ? explode(' ', $vocabs) : array();
107 107
         $vocabObjects = array();
108
-        foreach($vocids as $vocid) {
108
+        foreach ($vocids as $vocid) {
109 109
             $vocabObjects[] = $this->model->getVocabulary($vocid);
110 110
         }
111 111
         $parameters->setVocabularies($vocabObjects);
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
         foreach ($parameters->getAdditionalFields() as $field) {
137 137
 
138 138
             // Quick-and-dirty compactification
139
-            $context[$field] = 'skos:' . $field;
139
+            $context[$field] = 'skos:'.$field;
140 140
             foreach ($results as &$result) {
141 141
                 foreach ($result as $k => $v) {
142
-                    if ($k == 'skos:' . $field) {
142
+                    if ($k == 'skos:'.$field) {
143 143
                         $result[$field] = $v;
144
-                        unset($result['skos:' . $field]);
144
+                        unset($result['skos:'.$field]);
145 145
                     }
146 146
                 }
147 147
             }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         if ($request->getQueryParam('labellang')) {
161 161
             $ret['@context']['@language'] = $request->getQueryParam('labellang');
162 162
         } elseif ($request->getQueryParam('lang')) {
163
-            $ret['@context']['@language'] = $request->getQueryParam('lang');;
163
+            $ret['@context']['@language'] = $request->getQueryParam('lang'); ;
164 164
         }
165 165
         return $ret;
166 166
     }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
                 'prefLabel' => 'skos:prefLabel',
227 227
                 'title' => 'dct:title',
228 228
                 '@language' => $request->getLang(),
229
-                '@base' => $this->getBaseHref() . "rest/v1/" . $vocab->getId() . "/",
229
+                '@base' => $this->getBaseHref()."rest/v1/".$vocab->getId()."/",
230 230
             ),
231 231
             'uri' => '',
232 232
             'id' => $vocab->getId(),
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                 'subTypes' => array('@id' => 'void:class', '@type' => '@id'),
278 278
                 'count' => 'void:entities',
279 279
                 '@language' => $request->getLang(),
280
-                '@base' => $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/",
280
+                '@base' => $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/",
281 281
             ),
282 282
             'uri' => '',
283 283
             'id' => $request->getVocab()->getId(),
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
                 'language' => 'void-ext:language',
352 352
                 'properties' => 'void:propertyPartition',
353 353
                 'labels' => 'void:triples',
354
-                '@base' => $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/",
354
+                '@base' => $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/",
355 355
             ),
356 356
             'uri' => '',
357 357
             'id' => $request->getVocab()->getId(),
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
             $types[] = $type;
389 389
         }
390 390
 
391
-        $base = $request->getVocab() ? $this->getBaseHref() . "rest/v1/" . $request->getVocab()->getId() . "/" : $this->getBaseHref() . "rest/v1/";
391
+        $base = $request->getVocab() ? $this->getBaseHref()."rest/v1/".$request->getVocab()->getId()."/" : $this->getBaseHref()."rest/v1/";
392 392
 
393 393
         $ret = array_merge_recursive($this->context, array(
394 394
             '@context' => array(
@@ -548,19 +548,19 @@  discard block
 block discarded – undo
548 548
 
549 549
         $format = $this->negotiateFormat(array_keys($urls), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format'));
550 550
         if (!$format) {
551
-            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . implode(' ', array_keys($urls)));
551
+            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".implode(' ', array_keys($urls)));
552 552
         }
553 553
 		if (is_array($urls[$format])) {
554 554
 			$arr = $urls[$format];
555 555
 			$dataLang = $request->getLang();
556 556
 			if (isset($arr[$dataLang])) {
557
-                header("Location: " . $arr[$dataLang]);
557
+                header("Location: ".$arr[$dataLang]);
558 558
 			} else {
559 559
 				$vocid = $request->getVocab()->getId();
560 560
 				return $this->returnError('404', 'Not Found', "No download source URL known for vocabulary $vocid in language $dataLang");
561 561
 			}
562 562
 		} else {
563
-            header("Location: " . $urls[$format]);
563
+            header("Location: ".$urls[$format]);
564 564
 		}
565 565
     }
566 566
 
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 
621 621
         $format = $this->negotiateFormat(explode(' ', self::SUPPORTED_FORMATS), $request->getServerConstant('HTTP_ACCEPT'), $request->getQueryParam('format'));
622 622
         if (!$format) {
623
-            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: " . self::SUPPORTED_FORMATS);
623
+            return $this->returnError(406, 'Not Acceptable', "Unsupported format. Supported MIME types are: ".self::SUPPORTED_FORMATS);
624 624
         }
625 625
 
626 626
         $vocid = $vocab ? $vocab->getId() : null;
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
                         }
815 815
                     }
816 816
                     // if the main concept scheme was not found, set 'top' to the first 'tops' (sorted alphabetically on the URIs)
817
-                    if (! isset($results[$uri]['top'])) {
817
+                    if (!isset($results[$uri]['top'])) {
818 818
                         $results[$uri]['top'] = $results[$uri]['tops'][0];
819 819
                     }
820 820
                 } else {
Please login to merge, or discard this patch.