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

@@ 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}