Code Duplication    Length = 20-20 lines in 2 locations

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

@@ 202-221 (lines=20) @@
199
   * @param FilterResponseEvent $event
200
   *   Response event.
201
   */
202
  public function propagateSelection(FilterResponseEvent $event) {
203
    $render = [
204
      'labels' => [
205
        '#markup' => 'Labels: ' . implode(', ', array_map(function (EntityInterface $item) {return $item->label();}, $this->entities)),
206
        '#attached' => [
207
          'library' => ['entity_browser/iframe_selection'],
208
          'drupalSettings' => [
209
            'entity_browser' => [
210
              'iframe' => [
211
                'entities' => array_map(function (EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()];}, $this->entities),
212
                'uuid' => $this->request->query->get('uuid'),
213
              ],
214
            ],
215
          ],
216
        ],
217
      ],
218
    ];
219
220
    $event->setResponse(new Response(\Drupal::service('bare_html_page_renderer')->renderBarePage($render, 'Entity browser', 'page')));
221
  }
222
223
  /**
224
   * {@inheritdoc}

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

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