Completed
Push — 8.x-1.x ( e2f153...09a174 )
by Janez
02:43
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.