@@ -279,7 +279,7 @@ |
||
279 | 279 | /** |
280 | 280 | * Helper function to return commands to return in AjaxResponse. |
281 | 281 | * |
282 | - * @return array |
|
282 | + * @return SelectEntitiesCommand[] |
|
283 | 283 | * An array of ajax commands. |
284 | 284 | */ |
285 | 285 | public function getAjaxCommands(FormStateInterface $form_state) { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $uuid = $this->getUuid(); |
120 | 120 | $js_event_object = new RegisterJSCallbacks($this->configuration['entity_browser_id'], $uuid); |
121 | 121 | $js_event_object->registerCallback('Drupal.entityBrowser.selectionCompleted'); |
122 | - $js_event = $this->eventDispatcher->dispatch(Events::REGISTER_JS_CALLBACKS, $js_event_object ); |
|
122 | + $js_event = $this->eventDispatcher->dispatch(Events::REGISTER_JS_CALLBACKS, $js_event_object); |
|
123 | 123 | $original_path = $this->currentPath->getPath(); |
124 | 124 | $data = [ |
125 | 125 | 'query_parameters' => [ |
@@ -139,21 +139,21 @@ 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', |
153 | 153 | ], |
154 | 154 | '#attributes' => $data['attributes'], |
155 | 155 | '#attached' => [ |
156 | - 'library' => ['core/drupal.dialog.ajax', 'entity_browser/modal'], |
|
156 | + 'library' => ['core/drupal.dialog.ajax', 'entity_browser/modal'], |
|
157 | 157 | 'drupalSettings' => [ |
158 | 158 | 'entity_browser' => [ |
159 | 159 | 'modal' => [ |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | 'height' => $this->configuration['height'] - 90, |
201 | 201 | 'frameborder' => 0, |
202 | 202 | 'style' => 'padding:0', |
203 | - 'name' => 'entity-browser-iframe-' . Html::cleanCssIdentifier($element_name) |
|
203 | + 'name' => 'entity-browser-iframe-'.Html::cleanCssIdentifier($element_name) |
|
204 | 204 | ], |
205 | 205 | ]; |
206 | 206 | $html = drupal_render($content); |
207 | 207 | |
208 | 208 | $response = new AjaxResponse(); |
209 | - $response->addCommand(new OpenDialogCommand('#' . Html::getUniqueId($field_name . '-' . $element_name . '-dialog'), $this->configuration['link_text'], $html, [ |
|
209 | + $response->addCommand(new OpenDialogCommand('#'.Html::getUniqueId($field_name.'-'.$element_name.'-dialog'), $this->configuration['link_text'], $html, [ |
|
210 | 210 | 'width' => 'auto', |
211 | 211 | 'height' => 'auto', |
212 | 212 | 'modal' => TRUE, |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * An array of ajax commands. |
283 | 283 | */ |
284 | 284 | public function getAjaxCommands(FormStateInterface $form_state) { |
285 | - $entities = array_map(function(EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()];}, $form_state->get(['entity_browser', 'selected_entities'])); |
|
285 | + $entities = array_map(function(EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()]; }, $form_state->get(['entity_browser', 'selected_entities'])); |
|
286 | 286 | |
287 | 287 | $commands = []; |
288 | 288 | $commands[] = new SelectEntitiesCommand($this->uuid, $entities); |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | public function propagateSelection(FilterResponseEvent $event) { |
303 | 303 | $render = [ |
304 | 304 | 'labels' => [ |
305 | - '#markup' => 'Labels: ' . implode(', ', array_map(function (EntityInterface $item) {return $item->label();}, $this->entities)), |
|
305 | + '#markup' => 'Labels: '.implode(', ', array_map(function(EntityInterface $item) {return $item->label(); }, $this->entities)), |
|
306 | 306 | '#attached' => [ |
307 | 307 | 'library' => ['entity_browser/modal_selection'], |
308 | 308 | 'drupalSettings' => [ |
309 | 309 | 'entity_browser' => [ |
310 | 310 | 'modal' => [ |
311 | - 'entities' => array_map(function (EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()];}, $this->entities), |
|
311 | + 'entities' => array_map(function(EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()]; }, $this->entities), |
|
312 | 312 | 'uuid' => $this->request->query->get('uuid'), |
313 | 313 | ], |
314 | 314 | ], |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * {@inheritdoc} |
325 | 325 | */ |
326 | 326 | public function path() { |
327 | - return '/entity-browser/modal/' . $this->configuration['entity_browser_id']; |
|
327 | + return '/entity-browser/modal/'.$this->configuration['entity_browser_id']; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -336,7 +336,7 @@ |
||
336 | 336 | '_title_callback' => 'Drupal\entity_browser\Controllers\StandalonePage::title', |
337 | 337 | 'entity_browser_id' => $this->id(), |
338 | 338 | ], |
339 | - ['_permission' => 'access ' . $this->id() . ' entity browser pages'], |
|
339 | + ['_permission' => 'access '.$this->id().' entity browser pages'], |
|
340 | 340 | ['_admin_route' => \Drupal::config('node.settings')->get('use_admin_theme')] |
341 | 341 | ); |
342 | 342 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | |
64 | 64 | foreach ($browsers as $browser) { |
65 | 65 | if ($browser->route()) { |
66 | - $permissions['access ' . $browser->id() . ' entity browser pages'] = array( |
|
66 | + $permissions['access '.$browser->id().' entity browser pages'] = array( |
|
67 | 67 | 'title' => $this->translationManager->translate('Access @name pages', array('@name' => $browser->label())), |
68 | 68 | 'description' => $this->translationManager->translate('Access pages that %browser uses to operate.', array('%browser' => $browser->label())), |
69 | 69 | ); |
@@ -53,7 +53,7 @@ |
||
53 | 53 | $uploaded_files = $form_state->getValue(['upload'], []); |
54 | 54 | $trigger = $form_state->getTriggeringElement(); |
55 | 55 | // Only validate if we are uploading a file. |
56 | - if (empty($uploaded_files) && $trigger['#value'] == 'Upload') { |
|
56 | + if (empty($uploaded_files) && $trigger['#value'] == 'Upload') { |
|
57 | 57 | $form_state->setError($form['widget']['upload'], t('At least one file should be uploaded.')); |
58 | 58 | } |
59 | 59 | } |
@@ -72,9 +72,9 @@ |
||
72 | 72 | * @param \Drupal\Core\Session\AccountInterface $current_user |
73 | 73 | * The current user. |
74 | 74 | */ |
75 | - public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, EntityManagerInterface $entity_manager, AccountInterface $current_user) { |
|
76 | - parent::__construct($configuration, $plugin_id, $plugin_definition, $event_dispatcher, $entity_manager); |
|
77 | - $this->currentUser = $current_user; |
|
75 | + public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, EntityManagerInterface $entity_manager, AccountInterface $current_user) { |
|
76 | + parent::__construct($configuration, $plugin_id, $plugin_definition, $event_dispatcher, $entity_manager); |
|
77 | + $this->currentUser = $current_user; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -124,8 +124,7 @@ discard block |
||
124 | 124 | return [ |
125 | 125 | '#markup' => t('Entity browser select form field not found on a view. <a href=":link">Go fix it</a>!', [':link' => $url]), |
126 | 126 | ]; |
127 | - } |
|
128 | - else { |
|
127 | + } else { |
|
129 | 128 | return [ |
130 | 129 | '#markup' => t('Entity browser select form field not found on a view. Go fix it!'), |
131 | 130 | ]; |
@@ -183,8 +182,7 @@ discard block |
||
183 | 182 | ]); |
184 | 183 | $form_state->setError($form['widget']['view']['entity_browser_select'], $message); |
185 | 184 | } |
186 | - } |
|
187 | - catch (PluginNotFoundException $e) { |
|
185 | + } catch (PluginNotFoundException $e) { |
|
188 | 186 | $message = t('The Entity Type @type does not exist.', [ |
189 | 187 | '@type' => $parts[0], |
190 | 188 | ]); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $form['view'] = $view->executeDisplay($this->configuration['view_display']); |
117 | 117 | |
118 | 118 | if (empty($view->field['entity_browser_select'])) { |
119 | - $url = Url::fromRoute('entity.view.edit_form',['view'=>$this->configuration['view']])->toString(); |
|
119 | + $url = Url::fromRoute('entity.view.edit_form', ['view'=>$this->configuration['view']])->toString(); |
|
120 | 120 | if ($this->currentUser->hasPermission('administer views')) { |
121 | 121 | return [ |
122 | 122 | '#markup' => t('Entity browser select form field not found on a view. <a href=":link">Go fix it</a>!', [':link' => $url]), |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | foreach ($displays as $display) { |
221 | 221 | list($view_id, $display_id) = $display; |
222 | 222 | $view = $this->entityManager->getStorage('view')->load($view_id); |
223 | - $options[$view_id . '.' . $display_id] = $this->t('@view : @display', array('@view' => $view->label(), '@display' => $view->get('display')[$display_id]['display_title'])); |
|
223 | + $options[$view_id.'.'.$display_id] = $this->t('@view : @display', array('@view' => $view->label(), '@display' => $view->get('display')[$display_id]['display_title'])); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | $form['view'] = [ |
227 | 227 | '#type' => 'select', |
228 | 228 | '#title' => $this->t('View : View display'), |
229 | - '#default_value' => $this->configuration['view'] . '.' . $this->configuration['view_display'], |
|
229 | + '#default_value' => $this->configuration['view'].'.'.$this->configuration['view_display'], |
|
230 | 230 | '#options' => $options, |
231 | 231 | ]; |
232 | 232 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | /** |
25 | 25 | * {@inheritdoc} |
26 | 26 | */ |
27 | - public function getForm(array &$form = array(), FormStateInterface &$form_state = NULL) { |
|
27 | + public function getForm(array &$form = array(), FormStateInterface&$form_state = NULL) { |
|
28 | 28 | // Set a wrapper container for us to replace the form on ajax call. |
29 | 29 | $form['#prefix'] = '<div id="entity-browser-form">'; |
30 | 30 | $form['#suffix'] = '</div>'; |
@@ -24,7 +24,7 @@ |
||
24 | 24 | /** |
25 | 25 | * {@inheritdoc} |
26 | 26 | */ |
27 | - public function getForm(array &$form, FormStateInterface &$form_state) { |
|
27 | + public function getForm(array &$form, FormStateInterface&$form_state) { |
|
28 | 28 | return array(); |
29 | 29 | } |
30 | 30 |
@@ -24,10 +24,10 @@ |
||
24 | 24 | /** |
25 | 25 | * {@inheritdoc} |
26 | 26 | */ |
27 | - public function getForm(array &$form = array(), FormStateInterface &$form_state = NULL) { |
|
27 | + public function getForm(array &$form = array(), FormStateInterface&$form_state = NULL) { |
|
28 | 28 | $element = []; |
29 | 29 | foreach ($this->widget_ids as $id => $label) { |
30 | - $name = 'tab_selector_' . $id; |
|
30 | + $name = 'tab_selector_'.$id; |
|
31 | 31 | $element[$name] = array( |
32 | 32 | '#type' => 'button', |
33 | 33 | '#attributes' => ['class' => ['tab']], |
@@ -183,8 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | if (empty($entity_browser_id)) { |
185 | 185 | return [t('No entity browser selected.')]; |
186 | - } |
|
187 | - else { |
|
186 | + } else { |
|
188 | 187 | $browser = $this->entityManager->getStorage('entity_browser') |
189 | 188 | ->load($entity_browser_id); |
190 | 189 | $summary[] = t('Entity browser: @browser', ['@browser' => $browser->label()]); |
@@ -355,8 +354,7 @@ discard block |
||
355 | 354 | // information to return correct part of the form. |
356 | 355 | if (!empty($trigger['#ajax']['event']) && $trigger['#ajax']['event'] == 'entity_browser_value_updated') { |
357 | 356 | $parents = array_slice($trigger['#array_parents'], 0, -2); |
358 | - } |
|
359 | - elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], '_remove_')) { |
|
357 | + } elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], '_remove_')) { |
|
360 | 358 | $parents = array_slice($trigger['#array_parents'], 0, -4); |
361 | 359 | } |
362 | 360 |
@@ -16,8 +16,6 @@ |
||
16 | 16 | use Drupal\Core\Field\WidgetBase; |
17 | 17 | use Drupal\Core\Form\FormStateInterface; |
18 | 18 | use Drupal\Core\Plugin\ContainerFactoryPluginInterface; |
19 | -use Drupal\entity_browser\Events\Events; |
|
20 | -use Drupal\entity_browser\Events\RegisterJSCallbacks; |
|
21 | 19 | use Drupal\entity_browser\FieldWidgetDisplayManager; |
22 | 20 | use Symfony\Component\DependencyInjection\ContainerInterface; |
23 | 21 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
@@ -25,7 +25,6 @@ |
||
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Plugin implementation of the 'entity_reference' widget for entity browser. |
28 | - |
|
29 | 28 | * @FieldWidget( |
30 | 29 | * id = "entity_browser_entity_reference", |
31 | 30 | * label = @Translation("Entity browser"), |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | - $id = Html::getUniqueId('field-' . $this->fieldDefinition->getName() . '-display-settings-wrapper'); |
|
153 | + $id = Html::getUniqueId('field-'.$this->fieldDefinition->getName().'-display-settings-wrapper'); |
|
154 | 154 | $element['field_widget_display'] = [ |
155 | 155 | '#title' => t('Entity display plugin'), |
156 | 156 | '#type' => 'select', |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | '#type' => 'fieldset', |
185 | 185 | '#title' => t('Entity display plugin configuration'), |
186 | 186 | '#tree' => TRUE, |
187 | - '#prefix' => '<div id="' . $id . '">', |
|
187 | + '#prefix' => '<div id="'.$id.'">', |
|
188 | 188 | '#suffix' => '</div>', |
189 | 189 | ]; |
190 | 190 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * A key for form state storage. |
282 | 282 | */ |
283 | 283 | protected function getFormStateKey(FieldItemListInterface $items) { |
284 | - return $items->getEntity()->uuid() . ':' . $items->getFieldDefinition()->getName(); |
|
284 | + return $items->getEntity()->uuid().':'.$items->getFieldDefinition()->getName(); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | // Submit was triggered by one of the "Remove" buttons. We need to walk |
319 | 319 | // few levels up to read value of "target_id" element. |
320 | - elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], $this->fieldDefinition->getName() . '_remove_') === 0) { |
|
320 | + elseif ($trigger['#type'] == 'submit' && strpos($trigger['#name'], $this->fieldDefinition->getName().'_remove_') === 0) { |
|
321 | 321 | $parents = array_merge(array_slice($trigger['#parents'], 0, -static::$deleteDepth), ['target_id']); |
322 | 322 | } |
323 | 323 | |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | // results. |
355 | 355 | $form_state->set(['entity_browser_widget', $this->getFormStateKey($items)], $ids); |
356 | 356 | |
357 | - $hidden_id = Html::getUniqueId('edit-' . $this->fieldDefinition->getName() . '-target-id'); |
|
358 | - $details_id = Html::getUniqueId('edit-' . $this->fieldDefinition->getName()); |
|
357 | + $hidden_id = Html::getUniqueId('edit-'.$this->fieldDefinition->getName().'-target-id'); |
|
358 | + $details_id = Html::getUniqueId('edit-'.$this->fieldDefinition->getName()); |
|
359 | 359 | /** @var \Drupal\entity_browser\EntityBrowserInterface $entity_browser */ |
360 | 360 | $entity_browser = $this->entityManager->getStorage('entity_browser')->load($this->getSetting('entity_browser')); |
361 | 361 | |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | '#theme_wrappers' => ['container'], |
486 | 486 | '#attributes' => ['class' => ['entities-list']], |
487 | 487 | 'items' => array_map( |
488 | - function (ContentEntityInterface $entity) use ($field_widget_display, $details_id, $field_parents) { |
|
488 | + function(ContentEntityInterface $entity) use ($field_widget_display, $details_id, $field_parents) { |
|
489 | 489 | $display = $field_widget_display->view($entity); |
490 | 490 | if (is_string($display)) { |
491 | 491 | $display = ['#markup' => $display]; |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | 'wrapper' => $details_id, |
506 | 506 | ], |
507 | 507 | '#submit' => [[get_class($this), 'removeItemSubmit']], |
508 | - '#name' => $this->fieldDefinition->getName() . '_remove_' . $entity->id(), |
|
508 | + '#name' => $this->fieldDefinition->getName().'_remove_'.$entity->id(), |
|
509 | 509 | '#limit_validation_errors' => [array_merge($field_parents, [$this->fieldDefinition->getName()])], |
510 | 510 | '#attributes' => ['data-entity-id' => $entity->id()], |
511 | 511 | '#access' => (bool) $this->getSetting('field_widget_remove') |