Code Duplication    Length = 20-20 lines in 2 locations

src/Plugin/EntityBrowser/Display/IFrame.php 1 location

@@ 192-211 (lines=20) @@
189
   * @param FilterResponseEvent $event
190
   *   Response event.
191
   */
192
  public function propagateSelection(FilterResponseEvent $event) {
193
    $render = [
194
      'labels' => [
195
        '#markup' => 'Labels: ' . implode(', ', array_map(function (EntityInterface $item) {return $item->label();}, $this->entities)),
196
        '#attached' => [
197
          'library' => ['entity_browser/iframe_selection'],
198
          'drupalSettings' => [
199
            'entity_browser' => [
200
              'iframe' => [
201
                'entities' => array_map(function (EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()];}, $this->entities),
202
                'uuid' => $this->request->query->get('uuid'),
203
              ],
204
            ],
205
          ],
206
        ],
207
      ],
208
    ];
209
210
    $event->setResponse(new Response(\Drupal::service('bare_html_page_renderer')->renderBarePage($render, 'Entity browser', 'page')));
211
  }
212
213
  /**
214
   * {@inheritdoc}

src/Plugin/EntityBrowser/Display/Modal.php 1 location

@@ 307-326 (lines=20) @@
304
   * @param FilterResponseEvent $event
305
   *   Response event.
306
   */
307
  public function propagateSelection(FilterResponseEvent $event) {
308
    $render = [
309
      'labels' => [
310
        '#markup' => 'Labels: ' . implode(', ', array_map(function (EntityInterface $item) {return $item->label();}, $this->entities)),
311
        '#attached' => [
312
          'library' => ['entity_browser/modal_selection'],
313
          'drupalSettings' => [
314
            'entity_browser' => [
315
              'modal' => [
316
                'entities' => array_map(function (EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()];}, $this->entities),
317
                'uuid' => $this->request->query->get('uuid'),
318
              ],
319
            ],
320
          ],
321
        ],
322
      ],
323
    ];
324
325
    $event->setResponse(new Response(\Drupal::service('bare_html_page_renderer')->renderBarePage($render, 'Entity browser', 'entity_browser_propagation')));
326
  }
327
328
  /**
329
   * {@inheritdoc}