@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * Implements hook_inline_entity_form_reference_form_alter(). |
| 21 | 21 | */ |
| 22 | -function entity_browser_entity_form_inline_entity_form_reference_form_alter(&$reference_form, FormStateInterface &$form_state) { |
|
| 22 | +function entity_browser_entity_form_inline_entity_form_reference_form_alter(&$reference_form, FormStateInterface&$form_state) { |
|
| 23 | 23 | $entity_manager = \Drupal::entityManager(); |
| 24 | 24 | \Drupal::service('event_dispatcher') |
| 25 | 25 | ->addListener( |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $instance = $form_state->get(['inline_entity_form', $reference_form['#ief_id'], 'instance']); |
| 32 | 32 | |
| 33 | 33 | /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display */ |
| 34 | - $entity_form_id = $instance->getTargetEntityTypeId() . '.' . $instance->getTargetBundle() . '.default'; |
|
| 34 | + $entity_form_id = $instance->getTargetEntityTypeId().'.'.$instance->getTargetBundle().'.default'; |
|
| 35 | 35 | // TODO - 'default' might become configurable or something else in the future. |
| 36 | 36 | // See https://www.drupal.org/node/2510274 |
| 37 | 37 | $form_display = $entity_manager->getStorage('entity_form_display')->load($entity_form_id); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $form_values = NestedArray::getValue($form_state->getValues(), $reference_form['#parents']); |
| 130 | 130 | $storage = \Drupal::entityTypeManager()->getStorage($reference_form['#entity_type']); |
| 131 | 131 | $attach_entities = $storage->loadMultiple(explode(' ', $form_values['entity_id'])); |
| 132 | - $entities =& $form_state->get(['inline_entity_form', $ief_id, 'entities']); |
|
| 132 | + $entities = & $form_state->get(['inline_entity_form', $ief_id, 'entities']); |
|
| 133 | 133 | |
| 134 | 134 | // Determine the correct weight of the new element. |
| 135 | 135 | $weight = 0; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $definitions = $this->entityManager->getDefinitions(); |
| 66 | 66 | $entity_types = array_combine( |
| 67 | 67 | array_keys($definitions), |
| 68 | - array_map(function (EntityTypeInterface $item) { |
|
| 68 | + array_map(function(EntityTypeInterface $item) { |
|
| 69 | 69 | return $item->getLabel(); |
| 70 | 70 | }, $definitions) |
| 71 | 71 | ); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | $bundles = []; |
| 85 | 85 | if ($entity_type) { |
| 86 | 86 | $definitions = $this->entityManager->getBundleInfo($entity_type); |
| 87 | - $bundles = array_map(function ($item) { |
|
| 87 | + $bundles = array_map(function($item) { |
|
| 88 | 88 | return $item['label']; |
| 89 | 89 | }, $definitions); |
| 90 | 90 | } |
@@ -178,8 +178,8 @@ |
||
| 178 | 178 | $this->assertUrl('/admin/config/content/entity_browser/test_entity_browser/selection_display', ['query' => ['js' => 'nojs']]); |
| 179 | 179 | |
| 180 | 180 | $this->drupalPostForm(NULL, [], 'Next'); |
| 181 | - $this->assertFieldById('edit-table-' . $uuid . '-label', 'upload', 'Correct value for widget label found.'); |
|
| 182 | - $this->assertFieldById('edit-table-' . $uuid . '-form-upload-location', 'public://', 'Correct value for upload location found.'); |
|
| 181 | + $this->assertFieldById('edit-table-'.$uuid.'-label', 'upload', 'Correct value for widget label found.'); |
|
| 182 | + $this->assertFieldById('edit-table-'.$uuid.'-form-upload-location', 'public://', 'Correct value for upload location found.'); |
|
| 183 | 183 | |
| 184 | 184 | $this->drupalPostForm(NULL, [], 'Finish'); |
| 185 | 185 | |
@@ -143,7 +143,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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'), |
@@ -216,12 +216,10 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $display = ['#markup' => $display]; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $form['selected']['items_' . $entity->id()] = [ |
|
| 100 | + $form['selected']['items_'.$entity->id()] = [ |
|
| 101 | 101 | '#theme_wrappers' => ['container'], |
| 102 | 102 | '#attributes' => [ |
| 103 | 103 | 'class' => ['item-container'], |
@@ -108,10 +108,10 @@ discard block |
||
| 108 | 108 | '#type' => 'submit', |
| 109 | 109 | '#value' => $this->t('Remove'), |
| 110 | 110 | '#submit' => [[get_class($this), 'removeItemSubmit']], |
| 111 | - '#name' => 'remove_' . $entity->id(), |
|
| 111 | + '#name' => 'remove_'.$entity->id(), |
|
| 112 | 112 | '#attributes' => [ |
| 113 | 113 | 'data-row-id' => $id, |
| 114 | - 'data-remove-entity' => 'items_' . $entity->id(), |
|
| 114 | + 'data-remove-entity' => 'items_'.$entity->id(), |
|
| 115 | 115 | ], |
| 116 | 116 | ], |
| 117 | 117 | 'weight' => [ |
@@ -84,14 +84,14 @@ |
||
| 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).', |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | '#theme_wrappers' => ['container'], |
| 140 | 140 | 'path' => [ |
| 141 | 141 | '#type' => 'hidden', |
| 142 | - '#value' => Url::fromRoute('entity_browser.' . $this->configuration['entity_browser_id'], [], $data['query_parameters'])->toString(), |
|
| 142 | + '#value' => Url::fromRoute('entity_browser.'.$this->configuration['entity_browser_id'], [], $data['query_parameters'])->toString(), |
|
| 143 | 143 | ], |
| 144 | 144 | 'open_modal' => [ |
| 145 | 145 | '#type' => 'submit', |
| 146 | 146 | '#value' => $this->configuration['link_text'], |
| 147 | 147 | '#limit_validation_errors' => [], |
| 148 | 148 | '#submit' => [], |
| 149 | - '#name' => Html::getId('op_' . $this->configuration['entity_browser_id'] . '_' . $uuid), |
|
| 149 | + '#name' => Html::getId('op_'.$this->configuration['entity_browser_id'].'_'.$uuid), |
|
| 150 | 150 | '#ajax' => [ |
| 151 | 151 | 'callback' => [$this, 'openModal'], |
| 152 | 152 | 'event' => 'click', |
@@ -201,13 +201,13 @@ discard block |
||
| 201 | 201 | 'height' => $this->configuration['height'] - 90, |
| 202 | 202 | 'frameborder' => 0, |
| 203 | 203 | 'style' => 'padding:0', |
| 204 | - 'name' => 'entity_browser_iframe_' . Html::cleanCssIdentifier($element_name), |
|
| 204 | + 'name' => 'entity_browser_iframe_'.Html::cleanCssIdentifier($element_name), |
|
| 205 | 205 | ], |
| 206 | 206 | ]; |
| 207 | 207 | $html = drupal_render($content); |
| 208 | 208 | |
| 209 | 209 | $response = new AjaxResponse(); |
| 210 | - $response->addCommand(new OpenDialogCommand('#' . Html::getUniqueId($field_name . '-' . $element_name . '-dialog'), $this->configuration['link_text'], $html, [ |
|
| 210 | + $response->addCommand(new OpenDialogCommand('#'.Html::getUniqueId($field_name.'-'.$element_name.'-dialog'), $this->configuration['link_text'], $html, [ |
|
| 211 | 211 | 'width' => 'auto', |
| 212 | 212 | 'height' => 'auto', |
| 213 | 213 | 'modal' => TRUE, |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | public function propagateSelection(FilterResponseEvent $event) { |
| 306 | 306 | $render = [ |
| 307 | 307 | 'labels' => [ |
| 308 | - '#markup' => 'Labels: ' . implode(', ', array_map(function (EntityInterface $item) { |
|
| 308 | + '#markup' => 'Labels: '.implode(', ', array_map(function(EntityInterface $item) { |
|
| 309 | 309 | return $item->label(); |
| 310 | 310 | }, $this->entities)), |
| 311 | 311 | '#attached' => [ |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | 'drupalSettings' => [ |
| 314 | 314 | 'entity_browser' => [ |
| 315 | 315 | 'modal' => [ |
| 316 | - 'entities' => array_map(function (EntityInterface $item) { |
|
| 316 | + 'entities' => array_map(function(EntityInterface $item) { |
|
| 317 | 317 | return [$item->id(), $item->uuid(), $item->getEntityTypeId()]; |
| 318 | 318 | }, $this->entities), |
| 319 | 319 | 'uuid' => $this->request->query->get('uuid'), |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * {@inheritdoc} |
| 332 | 332 | */ |
| 333 | 333 | public function path() { |
| 334 | - return '/entity-browser/modal/' . $this->configuration['entity_browser_id']; |
|
| 334 | + return '/entity-browser/modal/'.$this->configuration['entity_browser_id']; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | /** |
@@ -148,7 +148,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | /** |
@@ -216,13 +216,13 @@ |
||
| 216 | 216 | foreach ($displays as $display) { |
| 217 | 217 | list($view_id, $display_id) = $display; |
| 218 | 218 | $view = $this->entityManager->getStorage('view')->load($view_id); |
| 219 | - $options[$view_id . '.' . $display_id] = $this->t('@view : @display', array('@view' => $view->label(), '@display' => $view->get('display')[$display_id]['display_title'])); |
|
| 219 | + $options[$view_id.'.'.$display_id] = $this->t('@view : @display', array('@view' => $view->label(), '@display' => $view->get('display')[$display_id]['display_title'])); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | $form['view'] = [ |
| 223 | 223 | '#type' => 'select', |
| 224 | 224 | '#title' => $this->t('View : View display'), |
| 225 | - '#default_value' => $this->configuration['view'] . '.' . $this->configuration['view_display'], |
|
| 225 | + '#default_value' => $this->configuration['view'].'.'.$this->configuration['view_display'], |
|
| 226 | 226 | '#options' => $options, |
| 227 | 227 | '#empty_option' => $this->t('- Select a view -'), |
| 228 | 228 | '#required' => TRUE, |