@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | // can't do much about it. |
51 | 51 | $selected_entities = $form_state->get(['entity_browser', 'selected_entities']); |
52 | 52 | if (!empty($selected_entities)) { |
53 | - $ids = array_map(function (EntityInterface $item) { |
|
53 | + $ids = array_map(function(EntityInterface $item) { |
|
54 | 54 | return $item->id(); |
55 | 55 | }, $selected_entities); |
56 | 56 | $storage['selection_display_view']->setArguments([implode(',', $ids)]); |
@@ -86,14 +86,14 @@ discard block |
||
86 | 86 | $views = Views::getAllViews(); |
87 | 87 | foreach ($views as $view_id => $view) { |
88 | 88 | foreach ($view->get('display') as $display_id => $display) { |
89 | - $options[$view_id . '.' . $display_id] = $this->t('@view : @display', array('@view' => $view->label(), '@display' => $display['display_title'])); |
|
89 | + $options[$view_id.'.'.$display_id] = $this->t('@view : @display', array('@view' => $view->label(), '@display' => $display['display_title'])); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | 93 | $form['view'] = [ |
94 | 94 | '#type' => 'select', |
95 | 95 | '#title' => $this->t('View : View display'), |
96 | - '#default_value' => $this->configuration['view'] . '.' . $this->configuration['view_display'], |
|
96 | + '#default_value' => $this->configuration['view'].'.'.$this->configuration['view_display'], |
|
97 | 97 | '#options' => $options, |
98 | 98 | '#required' => TRUE, |
99 | 99 | '#description' => $this->t('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).'), |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $display = ['#markup' => $display]; |
103 | 103 | } |
104 | 104 | |
105 | - $form['selected']['items_' . $entity->id() . '_' . $id] = [ |
|
105 | + $form['selected']['items_'.$entity->id().'_'.$id] = [ |
|
106 | 106 | '#theme_wrappers' => ['container'], |
107 | 107 | '#attributes' => [ |
108 | 108 | 'class' => ['item-container'], |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | '#type' => 'submit', |
114 | 114 | '#value' => $this->t('Remove'), |
115 | 115 | '#submit' => [[get_class($this), 'removeItemSubmit']], |
116 | - '#name' => 'remove_' . $entity->id() . '_' . $id, |
|
116 | + '#name' => 'remove_'.$entity->id().'_'.$id, |
|
117 | 117 | '#attributes' => [ |
118 | 118 | 'data-row-id' => $id, |
119 | - 'data-remove-entity' => 'items_' . $entity->id(), |
|
119 | + 'data-remove-entity' => 'items_'.$entity->id(), |
|
120 | 120 | ], |
121 | 121 | ], |
122 | 122 | 'weight' => [ |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | // Remove weight of entity being removed. |
159 | 159 | $form_state->unsetValue([ |
160 | 160 | 'selected', |
161 | - $triggering_element['#attributes']['data-remove-entity'] . '_' . $triggering_element['#attributes']['data-row-id'], |
|
161 | + $triggering_element['#attributes']['data-remove-entity'].'_'.$triggering_element['#attributes']['data-row-id'], |
|
162 | 162 | ]); |
163 | 163 | |
164 | 164 | // Remove entity itself. |
@@ -146,7 +146,7 @@ discard block |
||
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', |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | '#type' => 'fieldset', |
189 | 189 | '#title' => $this->t('Entity display plugin configuration'), |
190 | 190 | '#tree' => TRUE, |
191 | - '#prefix' => '<div id="' . $id . '">', |
|
191 | + '#prefix' => '<div id="'.$id.'">', |
|
192 | 192 | '#suffix' => '</div>', |
193 | 193 | ]; |
194 | 194 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * A key for form state storage. |
272 | 272 | */ |
273 | 273 | protected function getFormStateKey(FieldItemListInterface $items) { |
274 | - return $items->getEntity()->uuid() . ':' . $items->getFieldDefinition()->getName(); |
|
274 | + return $items->getEntity()->uuid().':'.$items->getFieldDefinition()->getName(); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | } |
308 | 308 | // Submit was triggered by one of the "Remove" buttons. We need to walk |
309 | 309 | // few levels up to read value of "target_id" element. |
310 | - elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], $this->fieldDefinition->getName() . '_remove_') === 0) { |
|
310 | + elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], $this->fieldDefinition->getName().'_remove_') === 0) { |
|
311 | 311 | $parents = array_merge(array_slice($trigger['#parents'], 0, -static::$deleteDepth), ['target_id']); |
312 | 312 | } |
313 | 313 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | |
346 | 346 | // Get correct ordered list of entity IDs. |
347 | 347 | $ids = array_map( |
348 | - function (EntityInterface $entity) { |
|
348 | + function(EntityInterface $entity) { |
|
349 | 349 | return $entity->id(); |
350 | 350 | }, |
351 | 351 | $entities |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | // might result in unpredictable results. |
360 | 360 | $form_state->set(['entity_browser_widget', $this->getFormStateKey($items)], $ids); |
361 | 361 | |
362 | - $hidden_id = Html::getUniqueId('edit-' . $this->fieldDefinition->getName() . '-target-id'); |
|
363 | - $details_id = Html::getUniqueId('edit-' . $this->fieldDefinition->getName()); |
|
362 | + $hidden_id = Html::getUniqueId('edit-'.$this->fieldDefinition->getName().'-target-id'); |
|
363 | + $details_id = Html::getUniqueId('edit-'.$this->fieldDefinition->getName()); |
|
364 | 364 | |
365 | 365 | $element += [ |
366 | 366 | '#id' => $details_id, |
@@ -375,8 +375,8 @@ discard block |
||
375 | 375 | // We need to repeat ID here as it is otherwise skipped when rendering. |
376 | 376 | '#attributes' => ['id' => $hidden_id], |
377 | 377 | '#default_value' => implode(' ', array_map( |
378 | - function (EntityInterface $item) { |
|
379 | - return $item->getEntityTypeId() . ':' . $item->id(); |
|
378 | + function(EntityInterface $item) { |
|
379 | + return $item->getEntityTypeId().':'.$item->id(); |
|
380 | 380 | }, |
381 | 381 | $entities |
382 | 382 | )), |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | public static function processEntityBrowser(&$element, FormStateInterface $form_state, &$complete_form) { |
427 | 427 | $uuid = key($element['#attached']['drupalSettings']['entity_browser']); |
428 | - $element['#attached']['drupalSettings']['entity_browser'][$uuid]['selector'] = '#' . $element['#custom_hidden_id']; |
|
428 | + $element['#attached']['drupalSettings']['entity_browser'][$uuid]['selector'] = '#'.$element['#custom_hidden_id']; |
|
429 | 429 | return $element; |
430 | 430 | } |
431 | 431 | |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | '#theme_wrappers' => ['container'], |
531 | 531 | '#attributes' => ['class' => ['entities-list']], |
532 | 532 | 'items' => array_map( |
533 | - function (ContentEntityInterface $entity, $row_id) use ($field_widget_display, $details_id, $field_parents) { |
|
533 | + function(ContentEntityInterface $entity, $row_id) use ($field_widget_display, $details_id, $field_parents) { |
|
534 | 534 | $display = $field_widget_display->view($entity); |
535 | 535 | if (is_string($display)) { |
536 | 536 | $display = ['#markup' => $display]; |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | '#theme_wrappers' => ['container'], |
540 | 540 | '#attributes' => [ |
541 | 541 | 'class' => ['item-container', Html::getClass($field_widget_display->getPluginId())], |
542 | - 'data-entity-id' => $entity->getEntityTypeId() . ':' . $entity->id(), |
|
542 | + 'data-entity-id' => $entity->getEntityTypeId().':'.$entity->id(), |
|
543 | 543 | 'data-row-id' => $row_id, |
544 | 544 | ], |
545 | 545 | 'display' => $display, |
@@ -551,10 +551,10 @@ discard block |
||
551 | 551 | 'wrapper' => $details_id, |
552 | 552 | ], |
553 | 553 | '#submit' => [[get_class($this), 'removeItemSubmit']], |
554 | - '#name' => $this->fieldDefinition->getName() . '_remove_' . $entity->id() . '_' . $row_id, |
|
554 | + '#name' => $this->fieldDefinition->getName().'_remove_'.$entity->id().'_'.$row_id, |
|
555 | 555 | '#limit_validation_errors' => [array_merge($field_parents, [$this->fieldDefinition->getName()])], |
556 | 556 | '#attributes' => [ |
557 | - 'data-entity-id' => $entity->getEntityTypeId() . ':' . $entity->id(), |
|
557 | + 'data-entity-id' => $entity->getEntityTypeId().':'.$entity->id(), |
|
558 | 558 | 'data-row-id' => $row_id, |
559 | 559 | ], |
560 | 560 | '#access' => (bool) $this->getSetting('field_widget_remove'), |
@@ -453,8 +453,7 @@ discard block |
||
453 | 453 | // and use this information to return correct part of the form. |
454 | 454 | if (!empty($trigger['#ajax']['event']) && $trigger['#ajax']['event'] == 'entity_browser_value_updated') { |
455 | 455 | $parents = array_slice($trigger['#array_parents'], 0, -1); |
456 | - } |
|
457 | - elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], '_remove_')) { |
|
456 | + } elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], '_remove_')) { |
|
458 | 457 | $parents = array_slice($trigger['#array_parents'], 0, -static::$deleteDepth); |
459 | 458 | } |
460 | 459 | |
@@ -621,12 +620,10 @@ discard block |
||
621 | 620 | $entity_browser_id = $this->getSetting('entity_browser'); |
622 | 621 | if (empty($entity_browser_id)) { |
623 | 622 | return [$this->t('No entity browser selected.')]; |
624 | - } |
|
625 | - else { |
|
623 | + } else { |
|
626 | 624 | if ($browser = $this->entityTypeManager->getStorage('entity_browser')->load($entity_browser_id)) { |
627 | 625 | $summary[] = $this->t('Entity browser: @browser', ['@browser' => $browser->label()]); |
628 | - } |
|
629 | - else { |
|
626 | + } else { |
|
630 | 627 | drupal_set_message($this->t('Missing entity browser!'), 'error'); |
631 | 628 | return [$this->t('Missing entity browser!')]; |
632 | 629 | } |
@@ -636,8 +633,7 @@ discard block |
||
636 | 633 | $selection_mode_options = EntityBrowserElement::getSelectionModeOptions(); |
637 | 634 | if (isset($selection_mode_options[$selection_mode])) { |
638 | 635 | $summary[] = $this->t('Selection mode: @selection_mode', ['@selection_mode' => $selection_mode_options[$selection_mode]]); |
639 | - } |
|
640 | - else { |
|
636 | + } else { |
|
641 | 637 | $summary[] = $this->t('Undefined selection mode.'); |
642 | 638 | } |
643 | 639 |