Code Duplication    Length = 20-20 lines in 2 locations

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

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

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

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