Completed
Push — 8.x-1.x ( e49ba2...ccc949 )
by Janez
03:32
created
src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
       }
147 147
     }
148 148
 
149
-    $id = Html::getUniqueId('field-' . $this->fieldDefinition->getName() . '-display-settings-wrapper');
149
+    $id = Html::getUniqueId('field-'.$this->fieldDefinition->getName().'-display-settings-wrapper');
150 150
     $element['field_widget_display'] = [
151 151
       '#title' => $this->t('Entity display plugin'),
152 152
       '#type' => 'select',
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
       '#type' => 'fieldset',
190 190
       '#title' => $this->t('Entity display plugin configuration'),
191 191
       '#tree' => TRUE,
192
-      '#prefix' => '<div id="' . $id . '">',
192
+      '#prefix' => '<div id="'.$id.'">',
193 193
       '#suffix' => '</div>',
194 194
     ];
195 195
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
    *   A key for form state storage.
273 273
    */
274 274
   protected function getFormStateKey(FieldItemListInterface $items) {
275
-    return $items->getEntity()->uuid() . ':' . $items->getFieldDefinition()->getName();
275
+    return $items->getEntity()->uuid().':'.$items->getFieldDefinition()->getName();
276 276
   }
277 277
 
278 278
   /**
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
     // Get correct ordered list of entity IDs.
286 286
     $ids = array_map(
287
-      function (EntityInterface $entity) {
287
+      function(EntityInterface $entity) {
288 288
         return $entity->id();
289 289
       },
290 290
       $entities
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
     // might result in unpredictable results.
299 299
     $form_state->set(['entity_browser_widget', $this->getFormStateKey($items)], $ids);
300 300
 
301
-    $hidden_id = Html::getUniqueId('edit-' . $this->fieldDefinition->getName() . '-target-id');
302
-    $details_id = Html::getUniqueId('edit-' . $this->fieldDefinition->getName());
301
+    $hidden_id = Html::getUniqueId('edit-'.$this->fieldDefinition->getName().'-target-id');
302
+    $details_id = Html::getUniqueId('edit-'.$this->fieldDefinition->getName());
303 303
 
304 304
     $element += [
305 305
       '#id' => $details_id,
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
         // We need to repeat ID here as it is otherwise skipped when rendering.
315 315
         '#attributes' => ['id' => $hidden_id],
316 316
         '#default_value' => implode(' ', array_map(
317
-            function (EntityInterface $item) {
318
-              return $item->getEntityTypeId() . ':' . $item->id();
317
+            function(EntityInterface $item) {
318
+              return $item->getEntityTypeId().':'.$item->id();
319 319
             },
320 320
             $entities
321 321
         )),
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
    */
365 365
   public static function processEntityBrowser(&$element, FormStateInterface $form_state, &$complete_form) {
366 366
     $uuid = key($element['#attached']['drupalSettings']['entity_browser']);
367
-    $element['#attached']['drupalSettings']['entity_browser'][$uuid]['selector'] = '#' . $element['#custom_hidden_id'];
367
+    $element['#attached']['drupalSettings']['entity_browser'][$uuid]['selector'] = '#'.$element['#custom_hidden_id'];
368 368
     return $element;
369 369
   }
370 370
 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
       '#theme_wrappers' => ['container'],
470 470
       '#attributes' => ['class' => ['entities-list']],
471 471
       'items' => array_map(
472
-        function (ContentEntityInterface $entity, $row_id) use ($field_widget_display, $details_id, $field_parents) {
472
+        function(ContentEntityInterface $entity, $row_id) use ($field_widget_display, $details_id, $field_parents) {
473 473
           $display = $field_widget_display->view($entity);
474 474
           if (is_string($display)) {
475 475
             $display = ['#markup' => $display];
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
             '#theme_wrappers' => ['container'],
479 479
             '#attributes' => [
480 480
               'class' => ['item-container', Html::getClass($field_widget_display->getPluginId())],
481
-              'data-entity-id' => $entity->getEntityTypeId() . ':' . $entity->id(),
481
+              'data-entity-id' => $entity->getEntityTypeId().':'.$entity->id(),
482 482
               'data-row-id' => $row_id,
483 483
             ],
484 484
             'display' => $display,
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
                 'wrapper' => $details_id,
491 491
               ],
492 492
               '#submit' => [[get_class($this), 'removeItemSubmit']],
493
-              '#name' => $this->fieldDefinition->getName() . '_remove_' . $entity->id() . '_' . $row_id,
493
+              '#name' => $this->fieldDefinition->getName().'_remove_'.$entity->id().'_'.$row_id,
494 494
               '#limit_validation_errors' => [array_merge($field_parents, [$this->fieldDefinition->getName()])],
495 495
               '#attributes' => [
496
-                'data-entity-id' => $entity->getEntityTypeId() . ':' . $entity->id(),
496
+                'data-entity-id' => $entity->getEntityTypeId().':'.$entity->id(),
497 497
                 'data-row-id' => $row_id,
498 498
               ],
499 499
               '#access' => (bool) $this->getSetting('field_widget_remove'),
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
       }
626 626
       // Submit was triggered by one of the "Remove" buttons. We need to walk
627 627
       // few levels up to read value of "target_id" element.
628
-      elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], $this->fieldDefinition->getName() . '_remove_') === 0) {
628
+      elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], $this->fieldDefinition->getName().'_remove_') === 0) {
629 629
         $parents = array_merge(array_slice($trigger['#parents'], 0, -static::$deleteDepth), ['target_id']);
630 630
       }
631 631
 
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
     // If an entity browser is being used in this widget, add it as a config
683 683
     // dependency.
684 684
     if ($browser_name = $this->getSetting('entity_browser')) {
685
-      $dependencies['config'][] = 'entity_browser.browser.' . $browser_name;
685
+      $dependencies['config'][] = 'entity_browser.browser.'.$browser_name;
686 686
     }
687 687
 
688 688
     return $dependencies;
Please login to merge, or discard this patch.