diff -u b/core/lib/Drupal/Core/Block/BlockBase.php b/core/lib/Drupal/Core/Block/BlockBase.php --- b/core/lib/Drupal/Core/Block/BlockBase.php +++ b/core/lib/Drupal/Core/Block/BlockBase.php @@ -10,8 +10,8 @@ use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\Plugin\PluginWithFormsInterface; +use Drupal\Core\Plugin\PluginWithFormsTrait; use Drupal\Core\Session\AccountInterface; use Drupal\Component\Transliteration\TransliterationInterface; @@ -27,6 +27,7 @@ abstract class BlockBase extends ContextAwarePluginBase implements BlockPluginInterface, PluginWithFormsInterface { use ContextAwarePluginAssignmentTrait; + use PluginWithFormsTrait; /** * The transliteration service. @@ -275,21 +276,2 @@ - /** - * {@inheritdoc} - */ - public function getFormClass($operation) { - if (isset($this->getPluginDefinition()['forms'][$operation])) { - return $this->getPluginDefinition()['forms'][$operation]; - } - elseif ($operation === 'configure') { - return static::class; - } - } - - /** - * {@inheritdoc} - */ - public function hasFormClass($operation) { - return !empty($this->getFormClass($operation)); - } - } diff -u b/core/lib/Drupal/Core/Plugin/PluginWithFormsTrait.php b/core/lib/Drupal/Core/Plugin/PluginWithFormsTrait.php --- b/core/lib/Drupal/Core/Plugin/PluginWithFormsTrait.php +++ b/core/lib/Drupal/Core/Plugin/PluginWithFormsTrait.php @@ -14,7 +14,7 @@ if (isset($this->getPluginDefinition()['forms'][$operation])) { return $this->getPluginDefinition()['forms'][$operation]; } - elseif ($operation === 'configure') { + elseif ($operation === 'configure' && $this instanceof PluginFormInterface) { return static::class; } } diff -u b/core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php b/core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php --- b/core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php @@ -3,6 +3,8 @@ namespace Drupal\Tests\Core\Plugin; use Drupal\Component\Plugin\PluginBase; +use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\PluginFormInterface; use Drupal\Core\Plugin\PluginWithFormsInterface; use Drupal\Core\Plugin\PluginWithFormsTrait; use Drupal\Tests\UnitTestCase; @@ -51,4 +53,15 @@ -class TestClass extends PluginBase implements PluginWithFormsInterface { +class TestClass extends PluginBase implements PluginWithFormsInterface, PluginFormInterface { use PluginWithFormsTrait; + + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + return []; + } + + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { + } + + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { + } + }