Completed
Pull Request — 8.x-1.x (#143)
by
unknown
02:38
created
src/Plugin/EntityBrowser/Display/Modal.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -279,7 +279,7 @@
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,6 @@  discard block
 block discarded – undo
12 12
 use Drupal\Core\Entity\EntityInterface;
13 13
 use Drupal\Core\Routing\RouteMatchInterface;
14 14
 use Drupal\Core\Url;
15
-use Drupal\entity_browser\DisplayAjaxInterface;
16 15
 use Drupal\entity_browser\DisplayBase;
17 16
 use Drupal\entity_browser\DisplayRouterInterface;
18 17
 use Drupal\entity_browser\Events\Events;
@@ -21,7 +20,6 @@  discard block
 block discarded – undo
21 20
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
22 21
 use Drupal\Core\Path\CurrentPathStack;
23 22
 use Drupal\Core\Ajax\AjaxResponse;
24
-use Drupal\Core\Ajax\CloseDialogCommand;
25 23
 use Drupal\entity_browser\Ajax\SelectEntitiesCommand;
26 24
 use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
27 25
 use Symfony\Component\HttpKernel\KernelEvents;
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
    */
71 71
   protected $uuid = NULL;
72 72
 
73
- /**
73
+  /**
74 74
    * Current request.
75 75
    *
76 76
    * @var \Symfony\Component\HttpFoundation\Request
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
   }
344 344
 
345 345
   /**
346
-    * {@inheritdoc}
347
-    */
346
+   * {@inheritdoc}
347
+   */
348 348
   public function setUuid($uuid) {
349 349
     $this->uuid = $uuid;
350 350
   }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
     // info.
140 140
     $event_object = new RegisterJSCallbacks($this->configuration['entity_browser_id'], $uuid);
141 141
     $event_object->registerCallback('Drupal.entityBrowser.selectionCompleted');
142
-    $event = $this->eventDispatcher->dispatch(Events::REGISTER_JS_CALLBACKS, $event_object );
142
+    $event = $this->eventDispatcher->dispatch(Events::REGISTER_JS_CALLBACKS, $event_object);
143 143
     $original_path = $this->currentPath->getPath();
144 144
     return [
145 145
       '#theme_wrappers' => ['container'],
146 146
       'path' => [
147 147
         '#type' => 'hidden',
148
-        '#value' => Url::fromRoute('entity_browser.' . $this->configuration['entity_browser_id'], [], [
148
+        '#value' => Url::fromRoute('entity_browser.'.$this->configuration['entity_browser_id'], [], [
149 149
           'query' => [
150 150
             'uuid' => $uuid,
151 151
             'original_path' => $original_path,
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         '#value' => $this->configuration['link_text'],
158 158
         '#limit_validation_errors' => [],
159 159
         '#submit' => [],
160
-        '#name' => Html::getId('op_' . $this->configuration['entity_browser_id'] . '_' . $uuid),
160
+        '#name' => Html::getId('op_'.$this->configuration['entity_browser_id'].'_'.$uuid),
161 161
         '#ajax' => [
162 162
           'callback' => [$this, 'openModal'],
163 163
           'event' => 'click',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
           'data-uuid' => $uuid,
167 167
         ],
168 168
         '#attached' => [
169
-          'library' => ['core/drupal.dialog.ajax',  'entity_browser/modal'],
169
+          'library' => ['core/drupal.dialog.ajax', 'entity_browser/modal'],
170 170
           'drupalSettings' => [
171 171
             'entity_browser' => [
172 172
               'modal' => [
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
         'height' => $this->configuration['height'] - 90,
212 212
         'frameborder' => 0,
213 213
         'style' => 'padding:',
214
-        'name' => Html::cleanCssIdentifier('entity-browser-iframe-' . $this->configuration['entity_browser_id'])
214
+        'name' => Html::cleanCssIdentifier('entity-browser-iframe-'.$this->configuration['entity_browser_id'])
215 215
       ],
216 216
     ];
217 217
     $html = drupal_render($content);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
    *   An array of ajax commands.
288 288
    */
289 289
   public function getAjaxCommands(FormStateInterface $form_state) {
290
-    $entities = array_map(function(EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()];}, $form_state->get(['entity_browser', 'selected_entities']));
290
+    $entities = array_map(function(EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()]; }, $form_state->get(['entity_browser', 'selected_entities']));
291 291
 
292 292
     $commands = array();
293 293
     $commands[] = new SelectEntitiesCommand($this->uuid, $entities);
@@ -307,13 +307,13 @@  discard block
 block discarded – undo
307 307
   public function propagateSelection(FilterResponseEvent $event) {
308 308
     $render = [
309 309
       'labels' => [
310
-        '#markup' => 'Labels: ' . implode(', ', array_map(function (EntityInterface $item) {return $item->label();}, $this->entities)),
310
+        '#markup' => 'Labels: '.implode(', ', array_map(function(EntityInterface $item) {return $item->label(); }, $this->entities)),
311 311
         '#attached' => [
312 312
           'library' => ['entity_browser/modal_selection'],
313 313
           'drupalSettings' => [
314 314
             'entity_browser' => [
315 315
               'modal' => [
316
-                'entities' => array_map(function (EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()];}, $this->entities),
316
+                'entities' => array_map(function(EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()]; }, $this->entities),
317 317
                 'uuid' => $this->request->query->get('uuid'),
318 318
               ],
319 319
             ],
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
    * {@inheritdoc}
330 330
    */
331 331
   public function path() {
332
-    return '/entity-browser/modal/' . $this->configuration['entity_browser_id'];
332
+    return '/entity-browser/modal/'.$this->configuration['entity_browser_id'];
333 333
   }
334 334
 
335 335
   /**
Please login to merge, or discard this patch.
src/Entity/EntityBrowser.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -336,7 +336,7 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Form/EntityBrowserForm.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -116,8 +116,7 @@
 block discarded – undo
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
   }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
    * {@inheritdoc}
32 32
    */
33 33
   public function getFormId() {
34
-    return 'entity_browser_' . $this->entity_browser->id() . '_form';
34
+    return 'entity_browser_'.$this->entity_browser->id().'_form';
35 35
   }
36 36
 
37 37
   /**
Please login to merge, or discard this patch.
src/Permissions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
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
         );
Please login to merge, or discard this patch.
src/Plugin/EntityBrowser/SelectionDisplay/View.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
     // them only once. Reason for that is how SQL and Views work and we probably
52 52
     // can't do much about it.
53 53
     if (!empty($this->selectedEntities)) {
54
-      $ids = array_map(function(EntityInterface $item) {return $item->id();}, $this->selectedEntities);
54
+      $ids = array_map(function(EntityInterface $item) {return $item->id(); }, $this->selectedEntities);
55 55
       $storage['selection_display_view']->setArguments([implode(',', $ids)]);
56 56
     }
57 57
 
Please login to merge, or discard this patch.
src/Plugin/EntityBrowser/Widget/Upload.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
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
   }
Please login to merge, or discard this patch.
src/Plugin/EntityBrowser/Widget/View.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,9 +72,9 @@
 block discarded – undo
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
   /**
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -124,8 +124,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
               ]);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Plugin/EntityBrowser/WidgetSelector/DropDown.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
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>';
Please login to merge, or discard this patch.
src/Plugin/EntityBrowser/WidgetSelector/Single.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.