diff --git a/core/lib/Drupal/Core/Block/BlockManager.php b/core/lib/Drupal/Core/Block/BlockManager.php index 036933f..3c88bdc 100644 --- a/core/lib/Drupal/Core/Block/BlockManager.php +++ b/core/lib/Drupal/Core/Block/BlockManager.php @@ -8,7 +8,6 @@ use Drupal\Core\Plugin\CategorizingPluginManagerTrait; use Drupal\Core\Plugin\Context\ContextAwarePluginManagerTrait; use Drupal\Core\Plugin\DefaultPluginManager; -use Drupal\Core\Plugin\PluginFormInterface; /** * Manages discovery and instantiation of block plugins. @@ -49,12 +48,6 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac public function processDefinition(&$definition, $plugin_id) { parent::processDefinition($definition, $plugin_id); $this->processDefinitionCategory($definition); - - // If no default form is defined and this plugin implements - // \Drupal\Core\Plugin\PluginFormInterface, use that for the default form. - if (!isset($definition['form']['default']) && is_subclass_of($definition['class'], PluginFormInterface::class)) { - $definition['form']['default'] = $definition['class']; - } } /** diff --git a/core/modules/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php index d4b4c42..bd1366f 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -71,11 +71,11 @@ class BlockForm extends EntityForm { protected $contextRepository; /** - * The plugin form manager. + * The plugin form factory. * * @var \Drupal\Core\Plugin\PluginFormFactoryInterface */ - protected $pluginFormManager; + protected $pluginFormFactory; /** * Constructs a BlockForm object. @@ -90,16 +90,16 @@ class BlockForm extends EntityForm { * The language manager. * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler * The theme handler. - * @param \Drupal\Core\Plugin\PluginFormFactoryInterface $plugin_form_manager - * The plugin form manager. + * @param \Drupal\Core\Plugin\PluginFormFactoryInterface $plugin_form_factory + * The plugin form factory. */ - public function __construct(EntityManagerInterface $entity_manager, ExecutableManagerInterface $manager, ContextRepositoryInterface $context_repository, LanguageManagerInterface $language, ThemeHandlerInterface $theme_handler, PluginFormFactoryInterface $plugin_form_manager) { + public function __construct(EntityManagerInterface $entity_manager, ExecutableManagerInterface $manager, ContextRepositoryInterface $context_repository, LanguageManagerInterface $language, ThemeHandlerInterface $theme_handler, PluginFormFactoryInterface $plugin_form_factory) { $this->storage = $entity_manager->getStorage('block'); $this->manager = $manager; $this->contextRepository = $context_repository; $this->language = $language; $this->themeHandler = $theme_handler; - $this->pluginFormManager = $plugin_form_manager; + $this->pluginFormFactory = $plugin_form_factory; } /** @@ -435,7 +435,7 @@ public function getUniqueMachineName(BlockInterface $block) { * The plugin form for the block. */ protected function getPluginForm(BlockPluginInterface $block) { - return $this->pluginFormManager->createInstance($block, 'configuration'); + return $this->pluginFormFactory->createInstance($block, 'configuration'); } } diff --git a/core/modules/block/tests/src/Unit/BlockFormTest.php b/core/modules/block/tests/src/Unit/BlockFormTest.php index cb4bdc2..9d81555 100644 --- a/core/modules/block/tests/src/Unit/BlockFormTest.php +++ b/core/modules/block/tests/src/Unit/BlockFormTest.php @@ -56,11 +56,11 @@ class BlockFormTest extends UnitTestCase { protected $contextRepository; /** - * The plugin form manager. + * The plugin form factory. * * @var \Drupal\Core\Plugin\PluginFormFactoryInterface|\Prophecy\Prophecy\ProphecyInterface */ - protected $pluginFormManager; + protected $pluginFormFactory; /** * {@inheritdoc} @@ -79,7 +79,7 @@ protected function setUp() { ->method('getStorage') ->will($this->returnValue($this->storage)); - $this->pluginFormManager = $this->prophesize(PluginFormFactoryInterface::class); + $this->pluginFormFactory = $this->prophesize(PluginFormFactoryInterface::class); } /** @@ -108,7 +108,7 @@ public function testGetUniqueMachineName() { ->method('getQuery') ->will($this->returnValue($query)); - $block_form_controller = new BlockForm($this->entityManager, $this->conditionManager, $this->contextRepository, $this->language, $this->themeHandler, $this->pluginFormManager->reveal()); + $block_form_controller = new BlockForm($this->entityManager, $this->conditionManager, $this->contextRepository, $this->language, $this->themeHandler, $this->pluginFormFactory->reveal()); // Ensure that the block with just one other instance gets the next available // name suggestion. diff --git a/core/modules/outside_in/src/Block/BlockEntityOffCanvasForm.php b/core/modules/outside_in/src/Block/BlockEntityOffCanvasForm.php index 7f5c868..56ceba4 100644 --- a/core/modules/outside_in/src/Block/BlockEntityOffCanvasForm.php +++ b/core/modules/outside_in/src/Block/BlockEntityOffCanvasForm.php @@ -68,7 +68,7 @@ protected function submitVisibility(array $form, FormStateInterface $form_state) * {@inheritdoc} */ protected function getPluginForm(BlockPluginInterface $block) { - return $this->pluginFormManager->getFormObject($block, 'offcanvas', 'default'); + return $this->pluginFormFactory->createInstance($block, 'offcanvas', 'configuration'); } } diff --git a/core/modules/outside_in/src/Form/SystemBrandingOffCanvasForm.php b/core/modules/outside_in/src/Form/SystemBrandingOffCanvasForm.php index 13f037c..6e71c76 100644 --- a/core/modules/outside_in/src/Form/SystemBrandingOffCanvasForm.php +++ b/core/modules/outside_in/src/Form/SystemBrandingOffCanvasForm.php @@ -2,12 +2,10 @@ namespace Drupal\outside_in\Form; - -use Drupal\Component\Plugin\PluginAwareInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Plugin\PluginFormInterface; +use Drupal\Core\Plugin\PluginFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -15,7 +13,7 @@ * * @see outside_in_block_alter() */ -class SystemBrandingOffCanvasForm implements ContainerInjectionInterface, PluginAwareInterface, PluginFormInterface { +class SystemBrandingOffCanvasForm extends PluginFormBase implements ContainerInjectionInterface { /** * The plugin. @@ -53,13 +51,6 @@ public static function create(ContainerInterface $container) { /** * {@inheritdoc} */ - public function setPlugin($plugin) { - $this->plugin = $plugin; - } - - /** - * {@inheritdoc} - */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = $this->plugin->buildConfigurationForm($form, $form_state); diff --git a/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php b/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php index 997d7a8..627d42e 100644 --- a/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php +++ b/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php @@ -2,12 +2,12 @@ namespace Drupal\outside_in\Form; -use Drupal\Component\Plugin\PluginAwareInterface; +use Drupal\Component\Plugin\PluginInspectionInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Plugin\PluginFormInterface; +use Drupal\Core\Plugin\PluginFormBase; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RedirectDestinationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -20,7 +20,7 @@ * * @see outside_in_block_alter() */ -class SystemMenuOffCanvasForm implements ContainerInjectionInterface, PluginAwareInterface, PluginFormInterface { +class SystemMenuOffCanvasForm extends PluginFormBase implements ContainerInjectionInterface { use StringTranslationTrait; use RedirectDestinationTrait; @@ -116,7 +116,11 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s /** * Gets the entity form for this menu. * - * @return \Drupal\Core\Form\FormInterface + * @param \Drupal\system\MenuInterface $entity + * The menu entity. + * + * @return \Drupal\Core\Entity\EntityFormInterface + * The entity form. */ protected function getEntityForm(MenuInterface $entity) { $entity_form = $this->entityTypeManager->getFormObject('menu', 'edit'); @@ -145,12 +149,9 @@ protected function ensureFormState(FormStateInterface $form_state) { } /** - * Sets the plugin for this object. - * - * @param object $plugin - * The plugin. + * {@inheritdoc} */ - public function setPlugin($plugin) { + public function setPlugin(PluginInspectionInterface $plugin) { $this->plugin = $plugin; $this->entity = $this->menuStorage->load($this->plugin->getDerivativeId()); }