1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Drupal\graphql_twig\Form; |
4
|
|
|
|
5
|
|
|
use Drupal\Core\Config\ConfigFactoryInterface; |
6
|
|
|
use Drupal\Core\Form\FormStateInterface; |
7
|
|
|
use Drupal\Core\Path\AliasManagerInterface; |
8
|
|
|
use Drupal\Core\Form\ConfigFormBase; |
9
|
|
|
use Drupal\Core\Path\PathValidatorInterface; |
10
|
|
|
use Drupal\Core\Routing\RequestContext; |
11
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Configure graphql twig settings |
15
|
|
|
* |
16
|
|
|
* @internal |
17
|
|
|
*/ |
18
|
|
|
class GraphQLTwigSettingsForm extends ConfigFormBase { |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Constructs a SiteInformationForm object. |
23
|
|
|
* |
24
|
|
|
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory |
25
|
|
|
* The factory for configuration objects. |
26
|
|
|
* @param \Drupal\Core\Path\AliasManagerInterface $alias_manager |
|
|
|
|
27
|
|
|
* The path alias manager. |
28
|
|
|
* @param \Drupal\Core\Path\PathValidatorInterface $path_validator |
|
|
|
|
29
|
|
|
* The path validator. |
30
|
|
|
* @param \Drupal\Core\Routing\RequestContext $request_context |
|
|
|
|
31
|
|
|
* The request context. |
32
|
|
|
*/ |
33
|
|
|
public function __construct(ConfigFactoryInterface $config_factory) { |
34
|
|
|
parent::__construct($config_factory); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public static function create(ContainerInterface $container) { |
41
|
|
|
return new static( |
42
|
|
|
$container->get('config.factory') |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
|
|
public function getFormId() { |
50
|
|
|
return 'graphql_twig_settings'; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* {@inheritdoc} |
55
|
|
|
*/ |
56
|
|
|
protected function getEditableConfigNames() { |
57
|
|
|
return ['graphql_twig.settings']; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* {@inheritdoc} |
62
|
|
|
*/ |
63
|
|
|
public function buildForm(array $form, FormStateInterface $form_state) { |
64
|
|
|
$site_config = $this->config('graphql_twig.settings'); |
65
|
|
|
$debug_placement = $site_config->get('debug_placement'); |
66
|
|
|
|
67
|
|
|
$form['debug'] = [ |
68
|
|
|
'#type' => 'details', |
69
|
|
|
'#title' => t('Debug'), |
70
|
|
|
'#open' => TRUE, |
71
|
|
|
]; |
72
|
|
|
$form['debug']['debug_placement'] = [ |
73
|
|
|
'#type' => 'select', |
74
|
|
|
'#title' => t('Debug placement'), |
75
|
|
|
'#options' => [ |
76
|
|
|
'wrapped' => $this->t('wrapped'), |
77
|
|
|
'inside' => $this->t('inside'), |
78
|
|
|
], |
79
|
|
|
'#default_value' => $debug_placement, |
80
|
|
|
'#required' => TRUE, |
81
|
|
|
]; |
82
|
|
|
|
83
|
|
|
return parent::buildForm($form, $form_state); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* {@inheritdoc} |
88
|
|
|
*/ |
89
|
|
|
public function submitForm(array &$form, FormStateInterface $form_state) { |
90
|
|
|
$this->config('graphql_twig.settings') |
91
|
|
|
->set('debug_placement', $form_state->getValue('debug_placement')) |
92
|
|
|
->save(); |
93
|
|
|
|
94
|
|
|
parent::submitForm($form, $form_state); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
} |
98
|
|
|
|
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 methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.