Code Duplication    Length = 20-20 lines in 2 locations

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

@@ 182-201 (lines=20) @@
179
   * @param FilterResponseEvent $event
180
   *   Response event.
181
   */
182
  public function propagateSelection(FilterResponseEvent $event) {
183
    $render = [
184
      'labels' => [
185
        '#markup' => 'Labels: ' . implode(', ', array_map(function (EntityInterface $item) {return $item->label();}, $this->entities)),
186
        '#attached' => [
187
          'library' => ['entity_browser/iframe_selection'],
188
          'drupalSettings' => [
189
            'entity_browser' => [
190
              'iframe' => [
191
                'entities' => array_map(function (EntityInterface $item) {return [$item->id(), $item->uuid(), $item->getEntityTypeId()];}, $this->entities),
192
                'uuid' => $this->request->query->get('uuid'),
193
              ],
194
            ],
195
          ],
196
        ],
197
      ],
198
    ];
199
200
    $event->setResponse(new Response(\Drupal::service('bare_html_page_renderer')->renderBarePage($render, 'Entity browser', 'page')));
201
  }
202
203
  /**
204
   * {@inheritdoc}

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

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