Code Duplication    Length = 20-20 lines in 2 locations

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

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