@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $this->comment('Available configurations:'); |
70 | 70 | $config = \Config::get('oaipmh.harvests', null); |
71 | 71 | foreach (array_keys($config) as $key) { |
72 | - $this->comment(' - ' . $key); |
|
72 | + $this->comment(' - '.$key); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | return false; |
82 | 82 | } |
83 | - $harvestConfig = \Config::get('oaipmh.harvests.' . $this->argument('name'), null); |
|
83 | + $harvestConfig = \Config::get('oaipmh.harvests.'.$this->argument('name'), null); |
|
84 | 84 | if (is_null($harvestConfig)) { |
85 | 85 | $this->error('Unknown configuration specified.'); |
86 | 86 | $this->listConfigurations(); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | $harvestName = $this->argument('name'); |
132 | - $harvestConfig = \Config::get('oaipmh.harvests.' . $harvestName, null); |
|
132 | + $harvestConfig = \Config::get('oaipmh.harvests.'.$harvestName, null); |
|
133 | 133 | |
134 | 134 | $this->comment(''); |
135 | 135 | $this->info(sprintf('[%s] Starting harvest "%s"', |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | if ($this->option('from-dump')) { |
141 | 141 | $this->comment(' - From local dump'); |
142 | 142 | } else { |
143 | - $this->comment(' - Repo: ' . $harvestConfig['url']); |
|
144 | - $this->comment(' - Schema: ' . $harvestConfig['schema']); |
|
145 | - $this->comment(' - Set: ' . $harvestConfig['set']); |
|
143 | + $this->comment(' - Repo: '.$harvestConfig['url']); |
|
144 | + $this->comment(' - Schema: '.$harvestConfig['schema']); |
|
145 | + $this->comment(' - Set: '.$harvestConfig['set']); |
|
146 | 146 | |
147 | 147 | foreach (['from', 'until', 'resume', 'daily'] as $key) { |
148 | 148 | if (!is_null($this->option($key))) { |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | // For timing |
155 | 155 | $this->startTime = $this->batchTime = microtime(true) - 1; |
156 | 156 | |
157 | - \Event::listen('Colligator\Events\OaiPmhHarvestStatus', function ($event) { |
|
157 | + \Event::listen('Colligator\Events\OaiPmhHarvestStatus', function($event) { |
|
158 | 158 | $this->status($event->harvested, $event->position); |
159 | 159 | }); |
160 | 160 | |
161 | - \Event::listen('Colligator\Events\OaiPmhHarvestComplete', function ($event) { |
|
161 | + \Event::listen('Colligator\Events\OaiPmhHarvestComplete', function($event) { |
|
162 | 162 | $this->info(sprintf('[%s] Harvest complete, got %d records in %d seconds', |
163 | 163 | strftime('%Y-%m-%d %H:%M:%S'), |
164 | 164 | $event->count, |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | )); |
167 | 167 | }); |
168 | 168 | |
169 | - \Event::listen('Colligator\Events\JobError', function ($event) { |
|
170 | - \Log::error('[OaiPmhHarvest] ' . $event->msg); |
|
169 | + \Event::listen('Colligator\Events\JobError', function($event) { |
|
170 | + \Log::error('[OaiPmhHarvest] '.$event->msg); |
|
171 | 171 | $this->error($event->msg); |
172 | 172 | }); |
173 | 173 |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | $rec = MarcRecord::fromString($q); |
58 | 58 | |
59 | 59 | $itemMap = [ |
60 | - 'x' => 'location', // OBS: 1030310 |
|
61 | - 'y' => 'shelvinglocation', // OBS: k00475 |
|
60 | + 'x' => 'location', // OBS: 1030310 |
|
61 | + 'y' => 'shelvinglocation', // OBS: k00475 |
|
62 | 62 | 'c' => 'barcode', |
63 | 63 | 'z' => 'callcode', |
64 | 64 | 'a' => 'id', |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | try { |
194 | 194 | $doc->storeCover($biblio['cover_image']); |
195 | 195 | } catch (\ErrorException $e) { |
196 | - \Log::error('Failed to store cover: ' . $biblio['cover_image']); |
|
196 | + \Log::error('Failed to store cover: '.$biblio['cover_image']); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | try { |
209 | 209 | list($biblio, $holdings) = $this->parseRecord($record); |
210 | 210 | } catch (ParserException $e) { |
211 | - $this->error('Failed to parse MARC record. Error "' . $e->getMessage() . '" in: ' . $e->getFile() . ':' . $e->getLine() . "\nStack trace:\n" . $e->getTraceAsString()); |
|
211 | + $this->error('Failed to parse MARC record. Error "'.$e->getMessage().'" in: '.$e->getFile().':'.$e->getLine()."\nStack trace:\n".$e->getTraceAsString()); |
|
212 | 212 | |
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | 216 | $doc = $this->importParsedRecord($biblio, $holdings); |
217 | 217 | |
218 | - \Log::debug('[Marc21Importer] Imported ' . $doc->bibsys_id . ' as ' . $doc->id); |
|
218 | + \Log::debug('[Marc21Importer] Imported '.$doc->bibsys_id.' as '.$doc->id); |
|
219 | 219 | |
220 | 220 | if (!is_null($doc)) { |
221 | 221 | Event::fire(new Marc21RecordImported($doc->id)); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function fromDump() |
104 | 104 | { |
105 | - $files = Storage::disk('local')->files('harvests/' . $this->name); |
|
105 | + $files = Storage::disk('local')->files('harvests/'.$this->name); |
|
106 | 106 | $recordsHarvested = 0; |
107 | 107 | foreach ($files as $filename) { |
108 | 108 | if (!preg_match('/.xml$/', $filename)) { |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | |
125 | 125 | public function fromNetwork() |
126 | 126 | { |
127 | - $dest_path = 'harvests/' . $this->name . '/'; |
|
127 | + $dest_path = 'harvests/'.$this->name.'/'; |
|
128 | 128 | |
129 | 129 | Storage::disk('local')->deleteDir($dest_path); |
130 | 130 | |
131 | - $latest = $dest_path . 'latest.xml'; |
|
131 | + $latest = $dest_path.'latest.xml'; |
|
132 | 132 | |
133 | 133 | $client = new OaiPmhClient($this->url, [ |
134 | 134 | 'schema' => $this->schema, |
@@ -137,12 +137,12 @@ discard block |
||
137 | 137 | 'sleep-time-on-error' => $this->sleepTimeOnError, |
138 | 138 | ]); |
139 | 139 | |
140 | - $client->on('request.error', function ($msg) { |
|
140 | + $client->on('request.error', function($msg) { |
|
141 | 141 | $this->error($msg); |
142 | 142 | }); |
143 | 143 | |
144 | 144 | // Store each response to disk just in case |
145 | - $client->on('request.complete', function ($verb, $args, $body) use ($latest) { |
|
145 | + $client->on('request.complete', function($verb, $args, $body) use ($latest) { |
|
146 | 146 | Storage::disk('local')->put($latest, $body); |
147 | 147 | }); |
148 | 148 | |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | if ($this->resume != $records->getResumptionToken()) { |
167 | 167 | $this->resume = $records->getResumptionToken(); |
168 | 168 | if (is_null($this->resume)) { |
169 | - Storage::disk('local')->delete($dest_path . '/resumption_token'); |
|
169 | + Storage::disk('local')->delete($dest_path.'/resumption_token'); |
|
170 | 170 | } else { |
171 | - Storage::disk('local')->put($dest_path . '/resumption_token', $this->resume); |
|
171 | + Storage::disk('local')->put($dest_path.'/resumption_token', $this->resume); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } catch (BadRequestError $e) { |
202 | 202 | $this->error($e->getMessage()); |
203 | 203 | $this->error($e->getCode()); |
204 | - $this->error('Bad request. Attempt ' . $attempt . ' of 100. Sleeping 10 secs.'); |
|
204 | + $this->error('Bad request. Attempt '.$attempt.' of 100. Sleeping 10 secs.'); |
|
205 | 205 | if ($attempt > 100) { |
206 | 206 | throw $e; |
207 | 207 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function handle(DocumentsIndex $docIndex, Marc21Importer $importer) |
227 | 227 | { |
228 | - Log::info('[OaiPmhHarvestJob] Starting job. Requesting records from ' . ($this->start ?: '(no limit)') . ' until ' . ($this->until ?: '(no limit)') . '.'); |
|
228 | + Log::info('[OaiPmhHarvestJob] Starting job. Requesting records from '.($this->start ?: '(no limit)').' until '.($this->until ?: '(no limit)').'.'); |
|
229 | 229 | $this->docIndex = $docIndex; |
230 | 230 | $this->importer = $importer; |
231 | 231 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | |
247 | 247 | // $this->postProcess($this->importedDocuments); |
248 | - Log::info('[OaiPmhHarvestJob] Complete, got ' . $recordsHarvested . ' records.'); |
|
248 | + Log::info('[OaiPmhHarvestJob] Complete, got '.$recordsHarvested.' records.'); |
|
249 | 249 | |
250 | 250 | Event::fire(new OaiPmhHarvestComplete($recordsHarvested)); |
251 | 251 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | public function sanitizeForQuery($value) |
95 | 95 | { |
96 | 96 | $chars = preg_quote('\\+-&|!(){}[]^~*?:'); |
97 | - $value = preg_replace('/([' . $chars . '])/', '\\\\\1', $value); |
|
97 | + $value = preg_replace('/(['.$chars.'])/', '\\\\\1', $value); |
|
98 | 98 | |
99 | 99 | return $value; |
100 | 100 | // |
@@ -126,17 +126,17 @@ discard block |
||
126 | 126 | } |
127 | 127 | if ($request->has('collection')) { |
128 | 128 | $col = Collection::findOrFail($request->collection); |
129 | - $query[] = 'collections:"' . $this->sanitizeForQuery($col->name) . '"'; |
|
129 | + $query[] = 'collections:"'.$this->sanitizeForQuery($col->name).'"'; |
|
130 | 130 | } |
131 | 131 | if ($request->has('subject')) { |
132 | - $query[] = '(subjects.noubomn.prefLabel:"' . $this->sanitizeForQuery($request->subject) . '"' . |
|
133 | - ' OR subjects.NOTrBIB.prefLabel:"' . $this->sanitizeForQuery($request->subject) . '"' . |
|
134 | - ' OR genres.noubomn.prefLabel:"' . $this->sanitizeForQuery($request->subject) . '")'; |
|
132 | + $query[] = '(subjects.noubomn.prefLabel:"'.$this->sanitizeForQuery($request->subject).'"'. |
|
133 | + ' OR subjects.NOTrBIB.prefLabel:"'.$this->sanitizeForQuery($request->subject).'"'. |
|
134 | + ' OR genres.noubomn.prefLabel:"'.$this->sanitizeForQuery($request->subject).'")'; |
|
135 | 135 | // TODO: Vi bør vel antakelig skille mellom X som emne og X som form/sjanger ? |
136 | 136 | // Men da må frontend si fra hva den ønsker, noe den ikke gjør enda. |
137 | 137 | } |
138 | 138 | if ($request->has('genre')) { |
139 | - $query[] = 'genres.noubomn.prefLabel:"' . $this->sanitizeForQuery($request->genre) . '"'; |
|
139 | + $query[] = 'genres.noubomn.prefLabel:"'.$this->sanitizeForQuery($request->genre).'"'; |
|
140 | 140 | } |
141 | 141 | if ($request->has('real')) { |
142 | 142 | dd('`real` is (very) deprecated, please use `subject` instead.'); |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | public function getUsageCount($id, $type) |
175 | 175 | { |
176 | 176 | $this->getFullType($type); |
177 | - $arg = $type . '.' . $id; |
|
177 | + $arg = $type.'.'.$id; |
|
178 | 178 | if (is_null(array_get($this->usage, $arg))) { |
179 | 179 | $this->addToUsageCache($id, $type); |
180 | 180 | } |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | ->get(); |
204 | 204 | |
205 | 205 | foreach ($entity_ids as $sid) { |
206 | - array_set($this->usage, $type . '.' . $sid, 0); |
|
206 | + array_set($this->usage, $type.'.'.$sid, 0); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | foreach ($res as $row) { |
210 | - array_set($this->usage, $type . '.' . $row->entity_id, intval($row->doc_count)); |
|
210 | + array_set($this->usage, $type.'.'.$row->entity_id, intval($row->doc_count)); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | $query = \DB::table('entities') |
218 | 218 | ->select(['entity_id', 'entity_type', \DB::raw('count(document_id) as doc_count')]) |
219 | 219 | ->groupBy('entity_id', 'entity_type'); |
220 | - $query->chunk(5000, function ($rows) use ($typemap) { |
|
220 | + $query->chunk(5000, function($rows) use ($typemap) { |
|
221 | 221 | foreach ($rows as $row) { |
222 | 222 | $type = $typemap[$row->entity_type]; |
223 | - array_set($this->usage, $type . '.' . $row->entity_id, intval($row->doc_count)); |
|
223 | + array_set($this->usage, $type.'.'.$row->entity_id, intval($row->doc_count)); |
|
224 | 224 | } |
225 | 225 | }); |
226 | 226 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | { |
238 | 238 | $payload = $this->basePayload(); |
239 | 239 | if (!is_null($indexVersion)) { |
240 | - $payload['index'] = $this->esIndex . '_v' . $indexVersion; |
|
240 | + $payload['index'] = $this->esIndex.'_v'.$indexVersion; |
|
241 | 241 | } |
242 | 242 | $payload['id'] = $doc->id; |
243 | 243 | |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | try { |
248 | 248 | $this->client->index($payload); |
249 | 249 | } catch (BadRequest400Exception $e) { |
250 | - \Log::error('ElasticSearch returned error: ' . $e->getMessage() . '. Our request: ' . var_export($payload, true)); |
|
251 | - throw new \ErrorException('ElasticSearch failed to index the document ' . $doc->id . '. Please see the log for payload and full error response. Error message: ' . $e->getMessage()); |
|
250 | + \Log::error('ElasticSearch returned error: '.$e->getMessage().'. Our request: '.var_export($payload, true)); |
|
251 | + throw new \ErrorException('ElasticSearch failed to index the document '.$doc->id.'. Please see the log for payload and full error response. Error message: '.$e->getMessage()); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | if (is_null($version)) { |
270 | 270 | $version = $this->getCurrentVersion() + 1; |
271 | 271 | } |
272 | - $indexParams = ['index' => $this->esIndex . '_v' . $version]; |
|
272 | + $indexParams = ['index' => $this->esIndex.'_v'.$version]; |
|
273 | 273 | $indexParams['body']['settings']['analysis']['char_filter']['isbn_filter'] = [ |
274 | 274 | 'type' => 'pattern_replace', |
275 | 275 | 'pattern' => '-', |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | { |
312 | 312 | try { |
313 | 313 | $this->client->indices()->delete([ |
314 | - 'index' => $this->esIndex . '_v' . $version, |
|
314 | + 'index' => $this->esIndex.'_v'.$version, |
|
315 | 315 | ]); |
316 | 316 | } catch (Missing404Exception $e) { |
317 | 317 | # Didn't exist in the beginning, that's ok. |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | public function addAction(&$actions, $action, $version) |
322 | 322 | { |
323 | 323 | if ($version) { |
324 | - $actions[] = [$action => ['index' => $this->esIndex . '_v' . $version, 'alias' => $this->esIndex]]; |
|
324 | + $actions[] = [$action => ['index' => $this->esIndex.'_v'.$version, 'alias' => $this->esIndex]]; |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | public function versionExists($version) |
340 | 340 | { |
341 | - return $this->client->indices()->exists(['index' => $this->esIndex . '_v' . $version]); |
|
341 | + return $this->client->indices()->exists(['index' => $this->esIndex.'_v'.$version]); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | public function getCurrentVersion() |