77 * Abstract class for PluginSettingsForm implementation.
88 */
99
10+ use Drupal \Component \Plugin \PluginManagerInterface ;
1011use Drupal \Core \Form \ConfigFormBase ;
1112use Drupal \Core \Form \FormStateInterface ;
1213
@@ -20,36 +21,37 @@ abstract class PluginSettingsFormBase extends ConfigFormBase implements PluginSe
2021 *
2122 * @var \Drupal\Component\Plugin\PluginManagerInterface
2223 */
23- protected $ manager ;
24+ protected PluginManagerInterface $ manager ;
2425
2526 /**
2627 * {@inheritdoc}
2728 */
28- protected function getEditableConfigNames () {
29+ protected function getEditableConfigNames (): array {
2930 return [$ this ->getConfigId ()];
3031 }
3132
3233 /**
3334 * {@inheritdoc}
3435 */
35- public function getFormId () {
36+ public function getFormId (): string {
3637 return $ this ->getConfigName () . '_settings_form_ ' . $ this ->getPluginIdFromRequest ();
3738 }
3839
3940 /**
4041 * {@inheritdoc}
4142 */
42- public function buildForm (array $ form , FormStateInterface $ form_state ) {
43+ public function buildForm (array $ form , FormStateInterface $ form_state ): array {
4344 $ plugin_id = $ this ->getPluginIdFromRequest ();
4445 $ instance = $ this ->getPluginInstance ($ plugin_id );
4546 $ form = $ instance ->buildConfigurationForm ($ form , $ form_state );
47+
4648 return parent ::buildForm ($ form , $ form_state );
4749 }
4850
4951 /**
5052 * {@inheritdoc}
5153 */
52- public function validateForm (array &$ form , FormStateInterface $ form_state ) {
54+ public function validateForm (array &$ form , FormStateInterface $ form_state ): void {
5355 $ plugin_id = $ this ->getPluginIdFromRequest ();
5456 $ instance = $ this ->getPluginInstance ($ plugin_id );
5557 $ instance ->validateConfigurationForm ($ form , $ form_state );
@@ -58,7 +60,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
5860 /**
5961 * {@inheritdoc}
6062 */
61- public function submitForm (array &$ form , FormStateInterface $ form_state ) {
63+ public function submitForm (array &$ form , FormStateInterface $ form_state ): void {
6264 $ plugin_id = $ this ->getPluginIdFromRequest ();
6365 $ instance = $ this ->getPluginInstance ($ plugin_id );
6466 $ instance ->submitConfigurationForm ($ form , $ form_state );
@@ -77,6 +79,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
7779 */
7880 protected function getPluginIdFromRequest () {
7981 $ request = $ this ->getRequest ();
82+
8083 return $ request ->get ('_plugin_id ' );
8184 }
8285
@@ -89,11 +92,12 @@ protected function getPluginIdFromRequest() {
8992 * @return object
9093 * Plugin instance.
9194 *
92- * @throws PluginException
95+ * @throws \Drupal\Component\Plugin\Exception\ PluginException
9396 */
94- public function getPluginInstance ($ plugin_id ) {
97+ public function getPluginInstance ($ plugin_id ): object {
9598 $ configuration = $ this ->config ($ this ->getConfigId ())->get ();
9699 $ instance = $ this ->manager ->createInstance ($ plugin_id , $ configuration );
100+
97101 return $ instance ;
98102 }
99103
@@ -103,7 +107,7 @@ public function getPluginInstance($plugin_id) {
103107 * @return string
104108 * Configuration object name.
105109 */
106- protected function getConfigId () {
110+ protected function getConfigId (): string {
107111 return $ this ->getConfigName () . '. ' . $ this ->getPluginIdFromRequest ();
108112 }
109113
0 commit comments