@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | $default_value = implode(' ', array_map( |
66 | - function (EntityInterface $item) { |
|
67 | - return $item->getEntityTypeId() . ':' . $item->id(); |
|
66 | + function(EntityInterface $item) { |
|
67 | + return $item->getEntityTypeId().':'.$item->id(); |
|
68 | 68 | }, |
69 | 69 | $element['#default_value'] |
70 | 70 | )); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | ['validators' => $validators, 'selected_entities' => $element['#default_value']] |
86 | 86 | ); |
87 | 87 | |
88 | - $hidden_id = Html::getUniqueId($element['#id'] . '-target'); |
|
88 | + $hidden_id = Html::getUniqueId($element['#id'].'-target'); |
|
89 | 89 | $element['entity_ids'] = [ |
90 | 90 | '#type' => 'hidden', |
91 | 91 | '#id' => $hidden_id, |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $element['#attached']['drupalSettings']['entity_browser'] = [ |
98 | 98 | $entity_browser->getDisplay()->getUuid() => [ |
99 | 99 | 'cardinality' => $element['#cardinality'], |
100 | - 'selector' => '#' . $hidden_id, |
|
100 | + 'selector' => '#'.$hidden_id, |
|
101 | 101 | ], |
102 | 102 | ]; |
103 | 103 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | return array_map( |
140 | - function ($item) { |
|
140 | + function($item) { |
|
141 | 141 | list($entity_type, $entity_id) = explode(':', $item); |
142 | 142 | return \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity_id); |
143 | 143 | }, |
@@ -116,8 +116,7 @@ |
||
116 | 116 | |
117 | 117 | if (!$this->isSelectionCompleted($form_state)) { |
118 | 118 | $form_state->setRebuild(); |
119 | - } |
|
120 | - else { |
|
119 | + } else { |
|
121 | 120 | $entity_browser->getDisplay()->selectionCompleted($this->getSelectedEntities($form_state)); |
122 | 121 | } |
123 | 122 | } |
@@ -51,22 +51,22 @@ |
||
51 | 51 | $this->assertFieldByXPath("//input[@type='hidden' and @id='edit-fancy-entity-browser-target']", '', "Entity browser's hidden element found."); |
52 | 52 | |
53 | 53 | $edit = [ |
54 | - 'fancy_entity_browser[entity_ids]' => $this->nodes[0]->getEntityTypeId() . ':' . $this->nodes[0]->id() . ' ' . $this->nodes[1]->getEntityTypeId() . ':' . $this->nodes[1]->id(), |
|
54 | + 'fancy_entity_browser[entity_ids]' => $this->nodes[0]->getEntityTypeId().':'.$this->nodes[0]->id().' '.$this->nodes[1]->getEntityTypeId().':'.$this->nodes[1]->id(), |
|
55 | 55 | ]; |
56 | 56 | $this->drupalPostForm(NULL, $edit, 'Submit'); |
57 | - $expected = 'Selected entities: ' . $this->nodes[0]->label() . ', ' . $this->nodes[1]->label(); |
|
57 | + $expected = 'Selected entities: '.$this->nodes[0]->label().', '.$this->nodes[1]->label(); |
|
58 | 58 | $this->assertText($expected, 'Selected entities detected.'); |
59 | 59 | |
60 | - $default_entity = $this->nodes[0]->getEntityTypeId() . ':' . $this->nodes[0]->id(); |
|
60 | + $default_entity = $this->nodes[0]->getEntityTypeId().':'.$this->nodes[0]->id(); |
|
61 | 61 | $this->drupalGet('/test-element', ['query' => ['default_entity' => $default_entity]]); |
62 | 62 | $this->assertLink('Select entities', 0, 'Trigger link found.'); |
63 | 63 | $this->assertFieldByXPath("//input[@type='hidden' and @id='edit-fancy-entity-browser-target']", $default_entity, "Entity browser's hidden element found."); |
64 | 64 | |
65 | 65 | $edit = [ |
66 | - 'fancy_entity_browser[entity_ids]' => $this->nodes[1]->getEntityTypeId() . ':' . $this->nodes[1]->id() . ' ' . $this->nodes[0]->getEntityTypeId() . ':' . $this->nodes[0]->id(), |
|
66 | + 'fancy_entity_browser[entity_ids]' => $this->nodes[1]->getEntityTypeId().':'.$this->nodes[1]->id().' '.$this->nodes[0]->getEntityTypeId().':'.$this->nodes[0]->id(), |
|
67 | 67 | ]; |
68 | 68 | $this->drupalPostForm(NULL, $edit, 'Submit'); |
69 | - $expected = 'Selected entities: ' . $this->nodes[1]->label() . ', ' . $this->nodes[0]->label(); |
|
69 | + $expected = 'Selected entities: '.$this->nodes[1]->label().', '.$this->nodes[0]->label(); |
|
70 | 70 | $this->assertText($expected, 'Selected entities detected.'); |
71 | 71 | } |
72 | 72 |
@@ -276,7 +276,7 @@ |
||
276 | 276 | /** |
277 | 277 | * Run widget validators. |
278 | 278 | * |
279 | - * @param array $entities |
|
279 | + * @param \Drupal\Core\Entity\EntityInterface[] $entities |
|
280 | 280 | * Array of entity ids to validate. |
281 | 281 | * @param array $validators |
282 | 282 | * Array of widget validator ids. |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | $xpath = new \DOMXPath($dom); |
140 | 140 | foreach ($commands as $command) { |
141 | 141 | if ($command['command'] == 'insert' && $command['method'] == 'replaceWith') { |
142 | - $wrapperNode = $xpath->query('//*[@id="' . ltrim($command['selector'], '#') . '"]')->item(0); |
|
142 | + $wrapperNode = $xpath->query('//*[@id="'.ltrim($command['selector'], '#').'"]')->item(0); |
|
143 | 143 | $newDom = new \DOMDocument(); |
144 | - @$newDom->loadHTML('<div>' . $command['data'] . '</div>'); |
|
144 | + @$newDom->loadHTML('<div>'.$command['data'].'</div>'); |
|
145 | 145 | $newNode = @$dom->importNode($newDom->documentElement->firstChild->firstChild, TRUE); |
146 | 146 | $wrapperNode->parentNode->replaceChild($newNode, $wrapperNode); |
147 | 147 | $content = $dom->saveHTML(); |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | $this->assertUrl('/admin/config/content/entity_browser/test_entity_browser/selection_display', ['query' => ['js' => 'nojs']]); |
233 | 233 | |
234 | 234 | $this->drupalPostForm(NULL, [], 'Next'); |
235 | - $this->assertFieldById('edit-table-' . $first_uuid . '-label', 'upload', 'Correct value for widget label found.'); |
|
236 | - $this->assertFieldById('edit-table-' . $first_uuid . '-form-upload-location', 'public://', 'Correct value for upload location found.'); |
|
237 | - $this->assertFieldByXPath("//input[@data-drupal-selector='edit-table-" . $first_uuid . "-form-submit-text']", 'Select files', 'Correct value for submit text found.'); |
|
238 | - $this->assertFieldById('edit-table-' . $second_uuid . '-label', 'entity_form', 'Correct value for widget label found.'); |
|
239 | - $this->assertOptionSelectedWithDrupalSelector('edit-table-' . $second_uuid . '-form-entity-type', 'user', 'Correct value for entity type found.'); |
|
240 | - $this->assertOptionSelectedWithDrupalSelector('edit-table-' . $second_uuid . '-form-bundle-select', 'user', 'Correct value for bundle found.'); |
|
241 | - $this->assertOptionSelectedWithDrupalSelector('edit-table-' . $second_uuid . '-form-form-mode-form-select', 'register', 'Correct value for form modes found.'); |
|
242 | - $this->assertFieldByXPath("//input[@data-drupal-selector='edit-table-" . $second_uuid . "-form-submit-text']", 'But some are more equal than others', 'Correct value for submit text found.'); |
|
235 | + $this->assertFieldById('edit-table-'.$first_uuid.'-label', 'upload', 'Correct value for widget label found.'); |
|
236 | + $this->assertFieldById('edit-table-'.$first_uuid.'-form-upload-location', 'public://', 'Correct value for upload location found.'); |
|
237 | + $this->assertFieldByXPath("//input[@data-drupal-selector='edit-table-".$first_uuid."-form-submit-text']", 'Select files', 'Correct value for submit text found.'); |
|
238 | + $this->assertFieldById('edit-table-'.$second_uuid.'-label', 'entity_form', 'Correct value for widget label found.'); |
|
239 | + $this->assertOptionSelectedWithDrupalSelector('edit-table-'.$second_uuid.'-form-entity-type', 'user', 'Correct value for entity type found.'); |
|
240 | + $this->assertOptionSelectedWithDrupalSelector('edit-table-'.$second_uuid.'-form-bundle-select', 'user', 'Correct value for bundle found.'); |
|
241 | + $this->assertOptionSelectedWithDrupalSelector('edit-table-'.$second_uuid.'-form-form-mode-form-select', 'register', 'Correct value for form modes found.'); |
|
242 | + $this->assertFieldByXPath("//input[@data-drupal-selector='edit-table-".$second_uuid."-form-submit-text']", 'But some are more equal than others', 'Correct value for submit text found.'); |
|
243 | 243 | |
244 | 244 | $this->drupalPostForm(NULL, [], 'Finish'); |
245 | 245 |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | */ |
17 | 17 | protected function setDatabaseDumpFiles() { |
18 | 18 | $this->databaseDumpFiles = [ |
19 | - DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.bare.standard.php.gz', |
|
20 | - __DIR__ . '/../../tests/fixtures/update/entity_browser.update-hook-test.php', |
|
19 | + DRUPAL_ROOT.'/core/modules/system/tests/fixtures/update/drupal-8.bare.standard.php.gz', |
|
20 | + __DIR__.'/../../tests/fixtures/update/entity_browser.update-hook-test.php', |
|
21 | 21 | ]; |
22 | 22 | } |
23 | 23 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | ->get('entity_browser.browser.test_update'); |
53 | 53 | |
54 | 54 | $this->assertNull($browser->get('submit_text'), 'Old submit text is gone'); |
55 | - $this->assertEqual($browser->get('widgets.a4ad947c-9669-497c-9988-24351955a02f.settings.submit_text'), 'All animals are created equal','New submit text appears on the widget.'); |
|
55 | + $this->assertEqual($browser->get('widgets.a4ad947c-9669-497c-9988-24351955a02f.settings.submit_text'), 'All animals are created equal', 'New submit text appears on the widget.'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | } |
@@ -125,7 +125,7 @@ |
||
125 | 125 | $files = $this->prepareEntities($form, $form_state); |
126 | 126 | array_walk( |
127 | 127 | $files, |
128 | - function (FileInterface $file) { |
|
128 | + function(FileInterface $file) { |
|
129 | 129 | $file->setPermanent(); |
130 | 130 | $file->save(); |
131 | 131 | } |
@@ -180,8 +180,7 @@ discard block |
||
180 | 180 | // their styles in code. |
181 | 181 | if (isset($image_styles[$image_style_setting])) { |
182 | 182 | $preview_image_style = $this->t('Preview image style: @style', ['@style' => $image_styles[$image_style_setting]]); |
183 | - } |
|
184 | - else { |
|
183 | + } else { |
|
185 | 184 | $preview_image_style = $this->t('No preview image'); |
186 | 185 | } |
187 | 186 | } |
@@ -248,8 +247,7 @@ discard block |
||
248 | 247 | if ($image->isValid()) { |
249 | 248 | $width = $image->getWidth(); |
250 | 249 | $height = $image->getHeight(); |
251 | - } |
|
252 | - else { |
|
250 | + } else { |
|
253 | 251 | $width = $height = NULL; |
254 | 252 | } |
255 | 253 | |
@@ -261,8 +259,7 @@ discard block |
||
261 | 259 | '#style_name' => $widget_settings['preview_image_style'], |
262 | 260 | '#uri' => $uri, |
263 | 261 | ]; |
264 | - } |
|
265 | - else { |
|
262 | + } else { |
|
266 | 263 | $display = $this->entityTypeManager->getViewBuilder('file')->view($entity, $view_mode); |
267 | 264 | } |
268 | 265 | |
@@ -277,8 +274,7 @@ discard block |
||
277 | 274 | if ($field_type == 'file') { |
278 | 275 | $description = $item->description; |
279 | 276 | $display_field = $item->display; |
280 | - } |
|
281 | - elseif ($field_type == 'image') { |
|
277 | + } elseif ($field_type == 'image') { |
|
282 | 278 | $alt = $item->alt; |
283 | 279 | $title = $item->title; |
284 | 280 | } |
@@ -439,8 +435,7 @@ discard block |
||
439 | 435 | $extensions = isset($settings['file_extensions']) ? $settings['file_extensions'] : implode(' ', $supported_extensions); |
440 | 436 | $extensions = array_intersect(explode(' ', $extensions), $supported_extensions); |
441 | 437 | $validators['file_validate_extensions'] = [implode(' ', $extensions)]; |
442 | - } |
|
443 | - elseif (!empty($settings['file_extensions'])) { |
|
438 | + } elseif (!empty($settings['file_extensions'])) { |
|
444 | 439 | $validators['file_validate_extensions'] = [$settings['file_extensions']]; |
445 | 440 | } |
446 | 441 |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | $delta = 0; |
214 | 214 | |
215 | - $order_class = $field_machine_name . '-delta-order'; |
|
215 | + $order_class = $field_machine_name.'-delta-order'; |
|
216 | 216 | |
217 | 217 | $current = [ |
218 | 218 | '#type' => 'table', |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $current[$entity_id] = [ |
290 | 290 | '#attributes' => [ |
291 | 291 | 'class' => ['draggable'], |
292 | - 'data-entity-id' => $entity->getEntityTypeId() . ':' . $entity_id, |
|
292 | + 'data-entity-id' => $entity->getEntityTypeId().':'.$entity_id, |
|
293 | 293 | 'data-row-id' => $delta, |
294 | 294 | ], |
295 | 295 | 'display' => $display, |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | 'url' => Url::fromRoute('entity_browser.edit_form', ['entity_type' => $entity->getEntityTypeId(), 'entity' => $entity_id]), |
339 | 339 | ], |
340 | 340 | '#attributes' => [ |
341 | - 'data-entity-id' => $entity->getEntityTypeId() . ':' . $entity->id(), |
|
341 | + 'data-entity-id' => $entity->getEntityTypeId().':'.$entity->id(), |
|
342 | 342 | 'data-row-id' => $delta, |
343 | 343 | ], |
344 | 344 | '#access' => $can_edit, |
@@ -351,10 +351,10 @@ discard block |
||
351 | 351 | 'wrapper' => $details_id, |
352 | 352 | ], |
353 | 353 | '#submit' => [[get_class($this), 'removeItemSubmit']], |
354 | - '#name' => $field_machine_name . '_remove_' . $entity_id, |
|
354 | + '#name' => $field_machine_name.'_remove_'.$entity_id, |
|
355 | 355 | '#limit_validation_errors' => [array_merge($field_parents, [$field_machine_name, 'target_id'])], |
356 | 356 | '#attributes' => [ |
357 | - 'data-entity-id' => $entity->getEntityTypeId() . ':' . $entity->id(), |
|
357 | + 'data-entity-id' => $entity->getEntityTypeId().':'.$entity->id(), |
|
358 | 358 | 'data-row-id' => $delta, |
359 | 359 | ], |
360 | 360 | '#access' => (bool) $widget_settings['field_widget_remove'], |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | } |
411 | 411 | |
412 | 412 | // Return ourself as the structure doesn't match the default. |
413 | - usort($return, function ($a, $b) { |
|
413 | + usort($return, function($a, $b) { |
|
414 | 414 | return SortArray::sortByKeyInt($a, $b, '_weight'); |
415 | 415 | }); |
416 | 416 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | $data['validators']['file'] = ['validators' => $this->getFileValidators()]; |
471 | 471 | // Provide context for widgets to enhance their configuration. Currently |
472 | 472 | // we only know that "upload_location" is used. |
473 | - $data['widget_context']['upload_location'] = $settings['uri_scheme'] . '://' . $settings['file_directory']; |
|
473 | + $data['widget_context']['upload_location'] = $settings['uri_scheme'].'://'.$settings['file_directory']; |
|
474 | 474 | return $data; |
475 | 475 | } |
476 | 476 |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * {@inheritdoc} |
99 | 99 | */ |
100 | 100 | public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters) { |
101 | - if (empty($this->configuration['entity_type']) || empty($this->configuration['bundle']) || empty($this->configuration['form_mode'])) { |
|
101 | + if (empty($this->configuration['entity_type']) || empty($this->configuration['bundle']) || empty($this->configuration['form_mode'])) { |
|
102 | 102 | return ['#markup' => $this->t('The settings for this widget (Entity type, Bundle or Form mode) are not configured correctly.')]; |
103 | 103 | } |
104 | 104 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | // Pretend to be IEFs submit button. |
108 | 108 | $form['#submit'] = [['Drupal\inline_entity_form\ElementSubmit', 'trigger']]; |
109 | - $form['actions']['submit']['#ief_submit_trigger'] = TRUE; |
|
109 | + $form['actions']['submit']['#ief_submit_trigger'] = TRUE; |
|
110 | 110 | $form['actions']['submit']['#ief_submit_trigger_all'] = TRUE; |
111 | 111 | |
112 | 112 | $form['inline_entity_form'] = [ |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $entities = $this->prepareEntities($form, $form_state); |
135 | 135 | array_walk( |
136 | 136 | $entities, |
137 | - function (EntityInterface $entity) { |
|
137 | + function(EntityInterface $entity) { |
|
138 | 138 | $entity->save(); |
139 | 139 | } |
140 | 140 | ); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $definitions = $this->entityTypeManager->getDefinitions(); |
156 | 156 | $entity_types = array_combine( |
157 | 157 | array_keys($definitions), |
158 | - array_map(function (EntityTypeInterface $item) { |
|
158 | + array_map(function(EntityTypeInterface $item) { |
|
159 | 159 | return $item->getLabel(); |
160 | 160 | }, $definitions) |
161 | 161 | ); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $bundles = []; |
174 | 174 | if ($entity_type) { |
175 | 175 | $definitions = $this->entityTypeBundleInfo->getBundleInfo($entity_type); |
176 | - $bundles = array_map(function ($item) { |
|
176 | + $bundles = array_map(function($item) { |
|
177 | 177 | return $item['label']; |
178 | 178 | }, $definitions); |
179 | 179 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | '#options' => $bundles, |
187 | 187 | '#default_value' => $bundle, |
188 | 188 | ], |
189 | - '#attributes' => ['id' => 'bundle-wrapper-' . $this->uuid()], |
|
189 | + '#attributes' => ['id' => 'bundle-wrapper-'.$this->uuid()], |
|
190 | 190 | ]; |
191 | 191 | |
192 | 192 | $form['form_mode'] = [ |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | '#default_value' => $form_mode, |
198 | 198 | '#options' => $this->entityDisplayRepository->getFormModeOptions($entity_type), |
199 | 199 | ], |
200 | - '#attributes' => ['id' => 'form-mode-wrapper-' . $this->uuid()], |
|
200 | + '#attributes' => ['id' => 'form-mode-wrapper-'.$this->uuid()], |
|
201 | 201 | ]; |
202 | 202 | |
203 | 203 | return $form; |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function updateFormElements($form, FormStateInterface $form_state) { |
224 | 224 | $response = new AjaxResponse(); |
225 | - $response->addCommand(new ReplaceCommand('#bundle-wrapper-' . $this->uuid(), $this->updateBundle($form, $form_state))); |
|
226 | - $response->addCommand(new ReplaceCommand('#form-mode-wrapper-' . $this->uuid(), $this->updateFormMode($form, $form_state))); |
|
225 | + $response->addCommand(new ReplaceCommand('#bundle-wrapper-'.$this->uuid(), $this->updateBundle($form, $form_state))); |
|
226 | + $response->addCommand(new ReplaceCommand('#form-mode-wrapper-'.$this->uuid(), $this->updateFormMode($form, $form_state))); |
|
227 | 227 | return $response; |
228 | 228 | } |
229 | 229 |
@@ -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).'), |