Completed
Push — 8.x-1.x ( ffc922...5b7276 )
by Janez
02:53
created

EntityBrowserWizard   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 7
c 2
b 0
f 1
lcom 0
cbo 0
dl 0
loc 92
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getNextParameters() 0 6 1
A getWizardLabel() 0 3 1
A getMachineLabel() 0 3 1
A getEntityType() 0 3 1
A exists() 0 3 1
B getOperations() 0 24 1
1
<?php
2
3
namespace Drupal\entity_browser\Wizard;
4
5
use Drupal\Core\DependencyInjection\ClassResolverInterface;
6
use Drupal\Core\Entity\EntityManagerInterface;
7
use Drupal\Core\Form\FormBuilderInterface;
8
use Drupal\Core\Routing\RouteMatchInterface;
9
use Drupal\ctools\Wizard\EntityFormWizardBase;
10
use Drupal\entity_browser\Form\DisplayConfig;
11
use Drupal\entity_browser\Form\GeneralInfoConfig;
12
use Drupal\entity_browser\Form\SelectionDisplayConfig;
13
use Drupal\entity_browser\Form\WidgetsConfig;
14
use Drupal\entity_browser\Form\WidgetSelectorConfig;
15
use Drupal\user\SharedTempStoreFactory;
16
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
17
18
/**
19
 * Custom form wizard for entity browser configuration.
20
 */
21
class EntityBrowserWizard extends EntityFormWizardBase {
22
23
  /**
24
   * @param \Drupal\user\SharedTempStoreFactory $tempstore
25
   *   Tempstore Factory for keeping track of values in each step of the
26
   *   wizard.
27
   * @param \Drupal\Core\Form\FormBuilderInterface $builder
28
   *   The Form Builder.
29
   * @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver
30
   *   The class resolver.
31
   * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
32
   *   The event dispatcher.
33
   * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
34
   *   The entity manager.
35
   * @param $tempstore_id
36
   *   The shared temp store factory collection name.
37
   * @param null $machine_name
0 ignored issues
show
Bug introduced by
There is no parameter named $machine_name. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
38
   *   The SharedTempStore key for our current wizard values.
39
   * @param null $step
40
   *   The current active step of the wizard.
41
   */
42
  public function __construct(SharedTempStoreFactory $tempstore, FormBuilderInterface $builder, ClassResolverInterface $class_resolver, EventDispatcherInterface $event_dispatcher, EntityManagerInterface $entity_manager, RouteMatchInterface $route_match, $tempstore_id, $entity_browser = NULL, $step = 'general') {
43
    parent::__construct($tempstore, $builder, $class_resolver, $event_dispatcher, $entity_manager, $route_match, $tempstore_id, $entity_browser, $step);
44
  }
45
46
  /**
47
   * {@inheritdoc}
48
   */
49
  public function getNextParameters($cached_values) {
50
    $parameters = parent::getNextParameters($cached_values);
51
    $parameters['entity_browser'] = $parameters['machine_name'];
52
    unset($parameters['machine_name']);
53
    return $parameters;
54
  }
55
56
  /**
57
   * {@inheritdoc}
58
   */
59
  public function getWizardLabel() {
60
    return $this->t('Entity browser');
61
  }
62
63
  /**
64
   * {@inheritdoc}
65
   */
66
  public function getMachineLabel() {
67
    return $this->t('Label');
68
  }
69
70
  /**
71
   * {@inheritdoc}
72
   */
73
  public function getEntityType() {
74
    return 'entity_browser';
75
  }
76
77
  /**
78
   * {@inheritdoc}
79
   */
80
  public function exists() {
81
    return 'Drupal\entity_browser\Entity\EntityBrowser::load';
82
  }
83
84
  /**
85
   * {@inheritdoc}
86
   */
87
  public function getOperations($cached_values) {
88
    return [
89
      'general' => [
90
        'title' => $this->t('General information'),
91
        'form' => GeneralInfoConfig::class,
92
      ],
93
      'display' => [
94
        'title' => $this->t('Display'),
95
        'form' => DisplayConfig::class,
96
      ],
97
      'widget_selector' => [
98
        'title' => $this->t('Widget selector'),
99
        'form' => WidgetSelectorConfig::class,
100
      ],
101
      'selection_display' => [
102
        'title' => $this->t('Selection display'),
103
        'form' => SelectionDisplayConfig::class,
104
      ],
105
      'widgets' => [
106
        'title' => $this->t('Widgets'),
107
        'form' => WidgetsConfig::class,
108
      ],
109
    ];
110
  }
111
112
}
113