Conditions | 11 |
Paths | 13 |
Total Lines | 67 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 12 | ||
Bugs | 3 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
84 | public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters) { |
||
85 | $form = []; |
||
86 | // TODO - do we need better error handling for view and view_display (in case |
||
87 | // either of those is nonexistent or display not of correct type)? |
||
88 | |||
89 | $form['#attached']['library'] = ['entity_browser/view']; |
||
90 | |||
91 | /** @var \Drupal\views\ViewExecutable $view */ |
||
92 | $view = $this->entityManager |
||
93 | ->getStorage('view') |
||
94 | ->load($this->configuration['view']) |
||
95 | ->getExecutable(); |
||
96 | |||
97 | // Check if the current user has access to this view. |
||
98 | if (!$view->access($this->configuration['view_display'])) { |
||
99 | return [ |
||
100 | '#markup' => t('You do not have access to this View.'), |
||
101 | ]; |
||
102 | } |
||
103 | |||
104 | // Force AJAX as we are embedding a form within a form, and exposed filter |
||
105 | // actions will submit the entire EntityBrowserForm form, not the View. |
||
106 | $view->setAjaxEnabled(TRUE); |
||
107 | |||
108 | if (!empty($this->configuration['arguments'])) { |
||
109 | if (!empty($aditional_widget_parameters['path_parts'])) { |
||
110 | $arguments = []; |
||
111 | // Map configuration arguments with original path parts. |
||
112 | foreach ($this->configuration['arguments'] as $argument) { |
||
113 | $arguments[] = isset($aditional_widget_parameters['path_parts'][$argument]) ? $aditional_widget_parameters['path_parts'][$argument] : ''; |
||
114 | } |
||
115 | $view->setArguments(array_values($arguments)); |
||
116 | } |
||
117 | } |
||
118 | |||
119 | $form['view'] = $view->executeDisplay($this->configuration['view_display']); |
||
120 | |||
121 | if (empty($view->field['entity_browser_select'])) { |
||
122 | $url = Url::fromRoute('entity.view.edit_form',['view'=>$this->configuration['view']])->toString(); |
||
123 | if ($this->currentUser->hasPermission('administer views')) { |
||
124 | return [ |
||
125 | '#markup' => t('Entity browser select form field not found on a view. <a href=":link">Go fix it</a>!', [':link' => $url]), |
||
126 | ]; |
||
127 | } |
||
128 | else { |
||
129 | return [ |
||
130 | '#markup' => t('Entity browser select form field not found on a view. Go fix it!'), |
||
131 | ]; |
||
132 | } |
||
133 | } |
||
134 | |||
135 | // When rebuilding makes no sense to keep checkboxes that were previously |
||
136 | // selected. |
||
137 | if (!empty($form['view']['entity_browser_select']) && $form_state->isRebuilding()) { |
||
138 | foreach (Element::children($form['view']['entity_browser_select']) as $child) { |
||
139 | $form['view']['entity_browser_select'][$child]['#process'][] = ['\Drupal\entity_browser\Plugin\EntityBrowser\Widget\View', 'processCheckbox']; |
||
140 | $form['view']['entity_browser_select'][$child]['#process'][] = ['\Drupal\Core\Render\Element\Checkbox', 'processAjaxForm']; |
||
141 | $form['view']['entity_browser_select'][$child]['#process'][] = ['\Drupal\Core\Render\Element\Checkbox', 'processGroup']; |
||
142 | } |
||
143 | } |
||
144 | |||
145 | $form['view']['view'] = [ |
||
146 | '#markup' => \Drupal::service('renderer')->render($form['view']['view']), |
||
147 | ]; |
||
148 | |||
149 | return $form; |
||
150 | } |
||
151 | |||
217 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.