@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | EntityIdLookup $entityIdLookup, |
50 | 50 | RdfVocabulary $rdfVocabulary |
51 | 51 | ) { |
52 | - parent::__construct( $page, $context ); |
|
52 | + parent::__construct($page, $context); |
|
53 | 53 | $this->resultsSource = $resultsSource; |
54 | 54 | $this->entityIdLookup = $entityIdLookup; |
55 | 55 | $this->rdfVocabulary = $rdfVocabulary; |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * @param string $guid |
109 | 109 | * @return string |
110 | 110 | */ |
111 | - private function cleanupGuid( $guid ) { |
|
112 | - return preg_replace( '/[^\w-]/', '-', $guid ); |
|
111 | + private function cleanupGuid($guid) { |
|
112 | + return preg_replace('/[^\w-]/', '-', $guid); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -121,63 +121,63 @@ discard block |
||
121 | 121 | $response = $this->getRequest()->response(); |
122 | 122 | $this->getOutput()->disable(); |
123 | 123 | |
124 | - if ( !$this->resultsSource instanceof CachingResultsSource ) { |
|
124 | + if (!$this->resultsSource instanceof CachingResultsSource) { |
|
125 | 125 | // TODO: make configurable whether only cached results are returned |
126 | - $response->statusHeader( 501 ); // Not Implemented |
|
126 | + $response->statusHeader(501); // Not Implemented |
|
127 | 127 | return null; |
128 | 128 | } |
129 | 129 | |
130 | - $entityId = $this->entityIdLookup->getEntityIdForTitle( $this->getTitle() ); |
|
131 | - if ( $entityId === null ) { |
|
132 | - $response->statusHeader( 404 ); // Not Found |
|
130 | + $entityId = $this->entityIdLookup->getEntityIdForTitle($this->getTitle()); |
|
131 | + if ($entityId === null) { |
|
132 | + $response->statusHeader(404); // Not Found |
|
133 | 133 | return null; |
134 | 134 | } |
135 | - $revId = $this->getRequest()->getInt( 'revision' ); |
|
135 | + $revId = $this->getRequest()->getInt('revision'); |
|
136 | 136 | |
137 | - $results = $this->resultsSource->getStoredResults( $entityId, $revId ); |
|
138 | - if ( $results === null ) { |
|
139 | - $response->statusHeader( 204 ); // No Content |
|
137 | + $results = $this->resultsSource->getStoredResults($entityId, $revId); |
|
138 | + if ($results === null) { |
|
139 | + $response->statusHeader(204); // No Content |
|
140 | 140 | return null; |
141 | 141 | } |
142 | 142 | |
143 | 143 | $format = 'ttl'; // TODO: make format an option |
144 | 144 | |
145 | 145 | $writerFactory = new RdfWriterFactory(); |
146 | - $formatName = $writerFactory->getFormatName( $format ); |
|
147 | - $contentType = $writerFactory->getMimeTypes( $formatName )[0]; |
|
146 | + $formatName = $writerFactory->getFormatName($format); |
|
147 | + $contentType = $writerFactory->getMimeTypes($formatName)[0]; |
|
148 | 148 | |
149 | - $propertyRepo = $this->rdfVocabulary->getEntityRepositoryName( new NumericPropertyId( 'P1' ) ); |
|
149 | + $propertyRepo = $this->rdfVocabulary->getEntityRepositoryName(new NumericPropertyId('P1')); |
|
150 | 150 | $wds = $this->rdfVocabulary->statementNamespaceNames[$propertyRepo][RdfVocabulary::NS_STATEMENT]; |
151 | 151 | |
152 | - $writer = $writerFactory->getWriter( $formatName ); |
|
153 | - foreach ( [ $wds, RdfVocabulary::NS_ONTOLOGY ] as $ns ) { |
|
154 | - $writer->prefix( $ns, $this->rdfVocabulary->getNamespaceURI( $ns ) ); |
|
152 | + $writer = $writerFactory->getWriter($formatName); |
|
153 | + foreach ([$wds, RdfVocabulary::NS_ONTOLOGY] as $ns) { |
|
154 | + $writer->prefix($ns, $this->rdfVocabulary->getNamespaceURI($ns)); |
|
155 | 155 | } |
156 | 156 | $writer->start(); |
157 | 157 | $writtenAny = false; |
158 | 158 | |
159 | - foreach ( $results->getArray() as $checkResult ) { |
|
160 | - if ( $checkResult instanceof NullResult ) { |
|
159 | + foreach ($results->getArray() as $checkResult) { |
|
160 | + if ($checkResult instanceof NullResult) { |
|
161 | 161 | continue; |
162 | 162 | } |
163 | - if ( $checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS ) { |
|
163 | + if ($checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | $writtenAny = true; |
167 | - $writer->about( $wds, |
|
168 | - $this->cleanupGuid( $checkResult->getContextCursor()->getStatementGuid() ) ) |
|
169 | - ->say( RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint' ) |
|
170 | - ->is( $wds, |
|
171 | - $this->cleanupGuid( $checkResult->getConstraint()->getConstraintId() ) ); |
|
167 | + $writer->about($wds, |
|
168 | + $this->cleanupGuid($checkResult->getContextCursor()->getStatementGuid())) |
|
169 | + ->say(RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint') |
|
170 | + ->is($wds, |
|
171 | + $this->cleanupGuid($checkResult->getConstraint()->getConstraintId())); |
|
172 | 172 | } |
173 | 173 | $writer->finish(); |
174 | - if ( $writtenAny ) { |
|
175 | - $response->header( "Content-Type: $contentType; charset=UTF-8" ); |
|
174 | + if ($writtenAny) { |
|
175 | + $response->header("Content-Type: $contentType; charset=UTF-8"); |
|
176 | 176 | echo $writer->drain(); |
177 | 177 | } else { |
178 | 178 | // Do not output RDF if we haven't written any actual statements. Output 204 instead |
179 | 179 | $writer->drain(); |
180 | - $response->statusHeader( 204 ); // No Content |
|
180 | + $response->statusHeader(204); // No Content |
|
181 | 181 | } |
182 | 182 | return null; |
183 | 183 | } |