NoDisplay::getForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Drupal\entity_browser\Plugin\EntityBrowser\SelectionDisplay;
4
5
use Drupal\Core\Form\FormStateInterface;
6
use Drupal\entity_browser\SelectionDisplayBase;
7
8
/**
9
 * Does not show current selection and immediately delivers selected entities.
10
 *
11
 * @EntityBrowserSelectionDisplay(
12
 *   id = "no_display",
13
 *   label = @Translation("No selection display"),
14
 *   description = @Translation("Skips the current selection display and immediately delivers the entities selected."),
15
 *   acceptPreselection = FALSE,
16
 *   js_commands = FALSE
17
 * )
18
 */
19
class NoDisplay extends SelectionDisplayBase {
20
21
  /**
22
   * {@inheritdoc}
23
   */
24
  public function getForm(array &$original_form, FormStateInterface $form_state) {
25
    return [];
26
  }
27
28
  /**
29
   * {@inheritdoc}
30
   */
31
  public function submit(array &$form, FormStateInterface $form_state) {
32
    // Only finish selection if the form was submitted using main submit
33
    // element. This allows widgets to build multi-step workflows.
34
    if (!empty($form_state->getTriggeringElement()['#eb_widget_main_submit'])) {
35
      $this->selectionDone($form_state);
36
    }
37
  }
38
39
}
40