Completed
Push — 8.x-1.x ( 09a174...2d9790 )
by Janez
03:18
created
src/Plugin/EntityBrowser/SelectionDisplay/View.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,14 +84,14 @@
 block discarded – undo
84 84
     $views = Views::getAllViews();
85 85
     foreach ($views as $view_id => $view) {
86 86
       foreach ($view->get('display') as $display_id => $display) {
87
-        $options[$view_id . '.' . $display_id] = $this->t('@view : @display', array('@view' => $view->label(), '@display' => $display['display_title']));
87
+        $options[$view_id.'.'.$display_id] = $this->t('@view : @display', array('@view' => $view->label(), '@display' => $display['display_title']));
88 88
       }
89 89
     }
90 90
 
91 91
     $form['view'] = [
92 92
       '#type' => 'select',
93 93
       '#title' => $this->t('View : View display'),
94
-      '#default_value' => $this->configuration['view'] . '.' . $this->configuration['view_display'],
94
+      '#default_value' => $this->configuration['view'].'.'.$this->configuration['view_display'],
95 95
       '#options' => $options,
96 96
       '#required' => TRUE,
97 97
       '#description' => 'View display to use for displaying currently selected items. Do note that to get something usefull out of this display, its first contextual filter should be a filter on the primary identifier field of your entity type (e.g., Node ID, Media ID).',
Please login to merge, or discard this patch.
src/Plugin/EntityBrowser/Display/IFrame.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
             'entity_browser' => [
149 149
               'iframe' => [
150 150
                 $uuid => [
151
-                  'src' => Url::fromRoute('entity_browser.' . $this->configuration['entity_browser_id'], [], $data['query_parameters'])
151
+                  'src' => Url::fromRoute('entity_browser.'.$this->configuration['entity_browser_id'], [], $data['query_parameters'])
152 152
                     ->toString(),
153 153
                   'width' => $this->configuration['width'],
154 154
                   'height' => $this->configuration['height'],
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
   public function propagateSelection(FilterResponseEvent $event) {
183 183
     $render = [
184 184
       'labels' => [
185
-        '#markup' => 'Labels: ' . implode(', ', array_map(function (EntityInterface $item) {
185
+        '#markup' => 'Labels: '.implode(', ', array_map(function(EntityInterface $item) {
186 186
           return $item->label();
187 187
         }, $this->entities)),
188 188
         '#attached' => [
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
           'drupalSettings' => [
191 191
             'entity_browser' => [
192 192
               'iframe' => [
193
-                'entities' => array_map(function (EntityInterface $item) {
193
+                'entities' => array_map(function(EntityInterface $item) {
194 194
                   return [$item->id(), $item->uuid(), $item->getEntityTypeId()];
195 195
                 }, $this->entities),
196 196
                 'uuid' => $this->request->query->get('uuid'),
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
    * {@inheritdoc}
209 209
    */
210 210
   public function path() {
211
-    return '/entity-browser/iframe/' . $this->configuration['entity_browser_id'];
211
+    return '/entity-browser/iframe/'.$this->configuration['entity_browser_id'];
212 212
   }
213 213
 
214 214
   /**
Please login to merge, or discard this patch.
src/Tests/ConfigUITest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
     $xpath = new \DOMXPath($dom);
138 138
     foreach ($commands as $command) {
139 139
       if ($command['command'] == 'insert' && $command['method'] == 'replaceWith') {
140
-        $wrapperNode = $xpath->query('//*[@id="' . ltrim($command['selector'], '#') . '"]')->item(0);
140
+        $wrapperNode = $xpath->query('//*[@id="'.ltrim($command['selector'], '#').'"]')->item(0);
141 141
         $newDom = new \DOMDocument();
142
-        @$newDom->loadHTML('<div>' . $command['data'] . '</div>');
142
+        @$newDom->loadHTML('<div>'.$command['data'].'</div>');
143 143
         $newNode = @$dom->importNode($newDom->documentElement->firstChild->firstChild, TRUE);
144 144
         $wrapperNode->parentNode->replaceChild($newNode, $wrapperNode);
145 145
         $content = $dom->saveHTML();
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
     $this->assertUrl('/admin/config/content/entity_browser/test_entity_browser/selection_display', ['query' => ['js' => 'nojs']]);
229 229
 
230 230
     $this->drupalPostForm(NULL, [], 'Next');
231
-    $this->assertFieldById('edit-table-' . $first_uuid . '-label', 'upload', 'Correct value for widget label found.');
232
-    $this->assertFieldById('edit-table-' . $first_uuid . '-form-upload-location', 'public://', 'Correct value for upload location found.');
233
-    $this->assertFieldById('edit-table-' . $second_uuid . '-label', 'entity_form', 'Correct value for widget label found.');
234
-    $this->assertOptionSelectedWithDrupalSelector('edit-table-' . $second_uuid . '-form-entity-type', 'user', 'Correct value for entity type found.');
235
-    $this->assertOptionSelectedWithDrupalSelector('edit-table-' . $second_uuid . '-form-bundle-select', 'user', 'Correct value for bundle found.');
236
-    $this->assertOptionSelectedWithDrupalSelector('edit-table-' . $second_uuid . '-form-form-mode-form-select', 'register', 'Correct value for form modes found.');
231
+    $this->assertFieldById('edit-table-'.$first_uuid.'-label', 'upload', 'Correct value for widget label found.');
232
+    $this->assertFieldById('edit-table-'.$first_uuid.'-form-upload-location', 'public://', 'Correct value for upload location found.');
233
+    $this->assertFieldById('edit-table-'.$second_uuid.'-label', 'entity_form', 'Correct value for widget label found.');
234
+    $this->assertOptionSelectedWithDrupalSelector('edit-table-'.$second_uuid.'-form-entity-type', 'user', 'Correct value for entity type found.');
235
+    $this->assertOptionSelectedWithDrupalSelector('edit-table-'.$second_uuid.'-form-bundle-select', 'user', 'Correct value for bundle found.');
236
+    $this->assertOptionSelectedWithDrupalSelector('edit-table-'.$second_uuid.'-form-form-mode-form-select', 'register', 'Correct value for form modes found.');
237 237
 
238 238
     $this->drupalPostForm(NULL, [], 'Finish');
239 239
 
Please login to merge, or discard this patch.
modules/entity_form/src/Plugin/EntityBrowser/Widget/EntityForm.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
    * {@inheritdoc}
97 97
    */
98 98
   public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters) {
99
-    if (empty($this->configuration['entity_type']) || empty($this->configuration['bundle'])  || empty($this->configuration['form_mode'])) {
99
+    if (empty($this->configuration['entity_type']) || empty($this->configuration['bundle']) || empty($this->configuration['form_mode'])) {
100 100
       return ['#markup' => t('The settings for this widget (Entity type, Bundle or Form mode) are not configured correctly.')];
101 101
     }
102 102
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     $definitions = $this->entityTypeManager->getDefinitions();
138 138
     $entity_types = array_combine(
139 139
       array_keys($definitions),
140
-      array_map(function (EntityTypeInterface $item) {
140
+      array_map(function(EntityTypeInterface $item) {
141 141
         return $item->getLabel();
142 142
       }, $definitions)
143 143
     );
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     $bundles = [];
156 156
     if ($entity_type) {
157 157
       $definitions = $this->entityTypeBundleInfo->getBundleInfo($entity_type);
158
-      $bundles = array_map(function ($item) {
158
+      $bundles = array_map(function($item) {
159 159
         return $item['label'];
160 160
       }, $definitions);
161 161
     }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         '#options' => $bundles,
169 169
         '#default_value' => $bundle,
170 170
       ],
171
-      '#attributes' => ['id' => 'bundle-wrapper-' . $this->uuid()],
171
+      '#attributes' => ['id' => 'bundle-wrapper-'.$this->uuid()],
172 172
     ];
173 173
 
174 174
     $form['form_mode'] = [
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         '#default_value' => $form_mode,
180 180
         '#options' => $this->entityDisplayRepository->getFormModeOptions($entity_type),
181 181
       ],
182
-      '#attributes' => ['id' => 'form-mode-wrapper-' . $this->uuid()],
182
+      '#attributes' => ['id' => 'form-mode-wrapper-'.$this->uuid()],
183 183
     ];
184 184
 
185 185
     return $form;
@@ -204,8 +204,8 @@  discard block
 block discarded – undo
204 204
    */
205 205
   public function updateFormElements($form, FormStateInterface $form_state) {
206 206
     $response = new AjaxResponse();
207
-    $response->addCommand(new ReplaceCommand('#bundle-wrapper-' . $this->uuid(), $this->updateBundle($form, $form_state)));
208
-    $response->addCommand(new ReplaceCommand('#form-mode-wrapper-' . $this->uuid(), $this->updateFormMode($form, $form_state)));
207
+    $response->addCommand(new ReplaceCommand('#bundle-wrapper-'.$this->uuid(), $this->updateBundle($form, $form_state)));
208
+    $response->addCommand(new ReplaceCommand('#form-mode-wrapper-'.$this->uuid(), $this->updateFormMode($form, $form_state)));
209 209
     return $response;
210 210
   }
211 211
 
Please login to merge, or discard this patch.
src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
       }
144 144
     }
145 145
 
146
-    $id = Html::getUniqueId('field-' . $this->fieldDefinition->getName() . '-display-settings-wrapper');
146
+    $id = Html::getUniqueId('field-'.$this->fieldDefinition->getName().'-display-settings-wrapper');
147 147
     $element['field_widget_display'] = [
148 148
       '#title' => t('Entity display plugin'),
149 149
       '#type' => 'select',
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
       '#type' => 'fieldset',
178 178
       '#title' => t('Entity display plugin configuration'),
179 179
       '#tree' => TRUE,
180
-      '#prefix' => '<div id="' . $id . '">',
180
+      '#prefix' => '<div id="'.$id.'">',
181 181
       '#suffix' => '</div>',
182 182
     ];
183 183
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
    *   A key for form state storage.
276 276
    */
277 277
   protected function getFormStateKey(FieldItemListInterface $items) {
278
-    return $items->getEntity()->uuid() . ':' . $items->getFieldDefinition()->getName();
278
+    return $items->getEntity()->uuid().':'.$items->getFieldDefinition()->getName();
279 279
   }
280 280
 
281 281
   /**
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
       }
313 313
       // Submit was triggered by one of the "Remove" buttons. We need to walk
314 314
       // few levels up to read value of "target_id" element.
315
-      elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], $this->fieldDefinition->getName() . '_remove_') === 0) {
315
+      elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], $this->fieldDefinition->getName().'_remove_') === 0) {
316 316
         $parents = array_merge(array_slice($trigger['#parents'], 0, -static::$deleteDepth), ['target_id']);
317 317
       }
318 318
 
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
349 349
     // results.
350 350
     $form_state->set(['entity_browser_widget', $this->getFormStateKey($items)], $ids);
351 351
 
352
-    $hidden_id = Html::getUniqueId('edit-' . $this->fieldDefinition->getName() . '-target-id');
353
-    $details_id = Html::getUniqueId('edit-' . $this->fieldDefinition->getName());
352
+    $hidden_id = Html::getUniqueId('edit-'.$this->fieldDefinition->getName().'-target-id');
353
+    $details_id = Html::getUniqueId('edit-'.$this->fieldDefinition->getName());
354 354
     /** @var \Drupal\entity_browser\EntityBrowserInterface $entity_browser */
355 355
     $entity_browser = $this->entityManager->getStorage('entity_browser')->load($this->getSetting('entity_browser'));
356 356
 
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
       $element['#attached']['drupalSettings']['entity_browser'] = [
386 386
         $entity_browser->getDisplay()->getUuid() => [
387 387
           'cardinality' => $this->fieldDefinition->getFieldStorageDefinition()->getCardinality(),
388
-          'selector' => '#' . $element['target_id']['#attributes']['id'],
388
+          'selector' => '#'.$element['target_id']['#attributes']['id'],
389 389
         ],
390 390
       ];
391 391
     }
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
       '#theme_wrappers' => ['container'],
496 496
       '#attributes' => ['class' => ['entities-list']],
497 497
       'items' => array_map(
498
-        function (ContentEntityInterface $entity) use ($field_widget_display, $details_id, $field_parents) {
498
+        function(ContentEntityInterface $entity) use ($field_widget_display, $details_id, $field_parents) {
499 499
           $display = $field_widget_display->view($entity);
500 500
           if (is_string($display)) {
501 501
             $display = ['#markup' => $display];
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
                 'wrapper' => $details_id,
516 516
               ],
517 517
               '#submit' => [[get_class($this), 'removeItemSubmit']],
518
-              '#name' => $this->fieldDefinition->getName() . '_remove_' . $entity->id(),
518
+              '#name' => $this->fieldDefinition->getName().'_remove_'.$entity->id(),
519 519
               '#limit_validation_errors' => [array_merge($field_parents, [$this->fieldDefinition->getName()])],
520 520
               '#attributes' => ['data-entity-id' => $entity->id()],
521 521
               '#access' => (bool) $this->getSetting('field_widget_remove'),
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -216,12 +216,10 @@  discard block
 block discarded – undo
216 216
 
217 217
     if (empty($entity_browser_id)) {
218 218
       return [t('No entity browser selected.')];
219
-    }
220
-    else {
219
+    } else {
221 220
       if ($browser = $this->entityManager->getStorage('entity_browser')->load($entity_browser_id)) {
222 221
         $summary[] = t('Entity browser: @browser', ['@browser' => $browser->label()]);
223
-      }
224
-      else {
222
+      } else {
225 223
         drupal_set_message(t('Missing entity browser!'), 'error');
226 224
         return [t('Missing entity browser!')];
227 225
       }
@@ -421,8 +419,7 @@  discard block
 block discarded – undo
421 419
     // information to return correct part of the form.
422 420
     if (!empty($trigger['#ajax']['event']) && $trigger['#ajax']['event'] == 'entity_browser_value_updated') {
423 421
       $parents = array_slice($trigger['#array_parents'], 0, -1);
424
-    }
425
-    elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], '_remove_')) {
422
+    } elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], '_remove_')) {
426 423
       $parents = array_slice($trigger['#array_parents'], 0, -static::$deleteDepth);
427 424
     }
428 425
 
Please login to merge, or discard this patch.
src/Plugin/Field/FieldWidget/FileBrowserWidget.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 
228 228
     $delta = 0;
229 229
 
230
-    $order_class = $field_machine_name . '-delta-order';
230
+    $order_class = $field_machine_name.'-delta-order';
231 231
 
232 232
     $current = [
233 233
       '#type' => 'table',
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             'wrapper' => $details_id,
362 362
           ],
363 363
           '#submit' => [[get_class($this), 'removeItemSubmit']],
364
-          '#name' => $field_machine_name . '_remove_' . $entity_id,
364
+          '#name' => $field_machine_name.'_remove_'.$entity_id,
365 365
           '#limit_validation_errors' => [],
366 366
           '#attributes' => ['data-entity-id' => $entity_id],
367 367
           '#access' => (bool) $widget_settings['field_widget_remove'],
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
     }
417 417
 
418 418
     // Return ourself as the structure doesn't match the default.
419
-    usort($return, function ($a, $b) {
419
+    usort($return, function($a, $b) {
420 420
       return SortArray::sortByKeyInt($a, $b, '_weight');
421 421
     });
422 422
 
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
     $data['validators']['file'] = ['validators' => $this->getFileValidators()];
477 477
     // Provide context for widgets to enhance their configuration. Currently
478 478
     // we only know that "upload_location" is used.
479
-    $data['widget_context']['upload_location'] = $settings['uri_scheme'] . '://' . $settings['file_directory'];
479
+    $data['widget_context']['upload_location'] = $settings['uri_scheme'].'://'.$settings['file_directory'];
480 480
     return $data;
481 481
   }
482 482
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -177,8 +177,7 @@  discard block
 block discarded – undo
177 177
 
178 178
     if (empty($entity_browser_id)) {
179 179
       return [$this->t('No entity browser selected.')];
180
-    }
181
-    else {
180
+    } else {
182 181
       $browser = $this->entityTypeManager->getStorage('entity_browser')
183 182
         ->load($entity_browser_id);
184 183
       $summary[] = $this->t('Entity browser: @browser', ['@browser' => $browser->label()]);
@@ -194,8 +193,7 @@  discard block
 block discarded – undo
194 193
       // their styles in code.
195 194
       if (isset($image_styles[$image_style_setting])) {
196 195
         $preview_image_style = $this->t('Preview image style: @style', ['@style' => $image_styles[$image_style_setting]]);
197
-      }
198
-      else {
196
+      } else {
199 197
         $preview_image_style = $this->t('No preview image');
200 198
       }
201 199
     }
@@ -263,8 +261,7 @@  discard block
 block discarded – undo
263 261
         if ($image->isValid()) {
264 262
           $width = $image->getWidth();
265 263
           $height = $image->getHeight();
266
-        }
267
-        else {
264
+        } else {
268 265
           $width = $height = NULL;
269 266
         }
270 267
 
@@ -276,8 +273,7 @@  discard block
 block discarded – undo
276 273
           '#style_name' => $widget_settings['preview_image_style'],
277 274
           '#uri' => $uri,
278 275
         ];
279
-      }
280
-      else {
276
+      } else {
281 277
         $display = $this->entityTypeManager->getViewBuilder('file')->view($entity, $view_mode);
282 278
       }
283 279
 
@@ -292,8 +288,7 @@  discard block
 block discarded – undo
292 288
           if ($field_type == 'file') {
293 289
             $description = $item->description;
294 290
             $display_field = $item->display;
295
-          }
296
-          elseif ($field_type == 'image') {
291
+          } elseif ($field_type == 'image') {
297 292
             $alt = $item->alt;
298 293
             $title = $item->title;
299 294
           }
@@ -453,8 +448,7 @@  discard block
 block discarded – undo
453 448
       $extensions = isset($settings['file_extensions']) ? $settings['file_extensions'] : implode(' ', $supported_extensions);
454 449
       $extensions = array_intersect(explode(' ', $extensions), $supported_extensions);
455 450
       $validators['file_validate_extensions'] = [implode(' ', $extensions)];
456
-    }
457
-    elseif (!empty($settings['file_extensions'])) {
451
+    } elseif (!empty($settings['file_extensions'])) {
458 452
       $validators['file_validate_extensions'] = [$settings['file_extensions']];
459 453
     }
460 454
 
Please login to merge, or discard this patch.