Code Duplication    Length = 20-20 lines in 2 locations

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

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

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}