Completed
Pull Request — 8.x-1.x (#137)
by
unknown
03:53
created

EntityBrowserWizard::getOperations()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 25
rs 8.8571
c 2
b 0
f 0
cc 1
eloc 18
nc 1
nop 1
1
<?php
2
/**
3
 * @file
4
 * Contains \Drupal\entity_browser\Wizard\EntityBrowserWizard.
5
 */
6
namespace Drupal\entity_browser\Wizard;
7
8
use Drupal\Core\Form\FormStateInterface;
9
use Drupal\Core\Url;
10
use Drupal\ctools\Wizard\EntityFormWizardBase;
11
use Drupal\entity_browser\Form\DisplayConfig;
12
use Drupal\entity_browser\Form\GeneralInfoConfig;
13
use Drupal\entity_browser\Form\SelectionDisplayConfig;
14
use Drupal\entity_browser\Form\WidgetsConfig;
15
use Drupal\entity_browser\Form\WidgetSelectorConfig;
16
17
/**
18
 * Custom form wizard for entity browser configuration.
19
 */
20
class EntityBrowserWizard extends EntityFormWizardBase {
21
22
  /**
23
   * {@inheritdoc}
24
   */
25
  public function getWizardLabel() {
26
    return $this->t('Entity browser');
27
  }
28
29
  /**
30
   * {@inheritdoc}
31
   */
32
  public function getMachineLabel() {
33
    return $this->t('Label');
34
  }
35
36
  /**
37
   * {@inheritdoc}
38
   */
39
  public function getEntityType() {
40
    return 'entity_browser';
41
  }
42
43
  /**
44
   * {@inheritdoc}
45
   */
46
  public function exists() {
47
    return 'Drupal\entity_browser\Entity\EntityBrowser::load';
48
  }
49
50
  /**
51
   * {@inheritdoc}
52
   */
53
  public function getOperations($cached_values) {
54
    $a = 1;
0 ignored issues
show
Unused Code introduced by
$a is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
55
    return [
56
      'general' => [
57
        'title' => $this->t('General information'),
58
        'form' => GeneralInfoConfig::class,
59
      ],
60
      'display' => [
61
        'title' => $this->t('Display'),
62
        'form' => DisplayConfig::class,
63
      ],
64
      'widget_selector' => [
65
        'title' => $this->t('Widget selector'),
66
        'form' => WidgetSelectorConfig::class,
67
      ],
68
      'selection_display' => [
69
        'title' => $this->t('Selection display'),
70
        'form' => SelectionDisplayConfig::class,
71
      ],
72
      'widgets' => [
73
        'title' => $this->t('Widgets'),
74
        'form' => WidgetsConfig::class,
75
      ],
76
    ];
77
  }
78
79
  /**
80
   * {@inheritdoc}
81
   */
82
  public function finish(array &$form, FormStateInterface $form_state) {
83
    parent::finish($form, $form_state);
84
    $form_state->setRedirectUrl(Url::fromUri('internal:/'));
85
  }
86
87
}
88