diff --git a/core/modules/outside_in/outside_in.links.contextual.yml b/core/modules/outside_in/outside_in.links.contextual.yml index ee83136..05455f3 100644 --- a/core/modules/outside_in/outside_in.links.contextual.yml +++ b/core/modules/outside_in/outside_in.links.contextual.yml @@ -1,4 +1,4 @@ outside_in.block_configure: title: 'Quick Edit' - route_name: 'entity.block.edit_form' + route_name: 'entity.block.offcanvas_form' group: 'block' diff --git a/core/modules/outside_in/src/Block/BlockEntityOffcanvasForm.php b/core/modules/outside_in/src/Block/BlockEntityOffcanvasForm.php index 210b9e5..2c5ad58 100644 --- a/core/modules/outside_in/src/Block/BlockEntityOffcanvasForm.php +++ b/core/modules/outside_in/src/Block/BlockEntityOffcanvasForm.php @@ -70,7 +70,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['#tree'] = TRUE; $form['#attached']['library'][] = 'block/drupal.block.admin'; - $form['settings'] = $this->blockManager->getFormObject($this->entity->getPlugin(), 'sidebar')->buildConfigurationForm([], $form_state); + $form['settings'] = $this->blockManager->getFormObject($this->entity->getPlugin(), 'offcavnas')->buildConfigurationForm([], $form_state); return $form; } diff --git a/core/modules/outside_in/src/Block/OutsideInBlockManager.php b/core/modules/outside_in/src/Block/OutsideInBlockManager.php index f335d79..474f8a0 100644 --- a/core/modules/outside_in/src/Block/OutsideInBlockManager.php +++ b/core/modules/outside_in/src/Block/OutsideInBlockManager.php @@ -34,8 +34,15 @@ public function __construct(ClassResolverInterface $class_resolver) { */ public function getFormObject(PluginInspectionInterface $plugin, $operation) { $definition = $plugin->getPluginDefinition(); + if (!isset($definition['form'][$operation])) { - throw new InvalidPluginDefinitionException($plugin->getPluginId(), sprintf('The "%s" plugin did not specify a "%s" form class', $plugin->getPluginId(), $operation)); + // Use the default form class if no form is specified for this operation. + if (isset($definition['form']['default'])) { + $operation = 'default'; + } + else { + throw new InvalidPluginDefinitionException($plugin->getPluginId(), sprintf('The "%s" plugin did not specify a "%s" form class', $plugin->getPluginId(), $operation)); + } } // If the form specified is the plugin itself, use it directly. diff --git a/core/modules/outside_in/tests/modules/offcanvas_test/src/Form/OffcanvasForm.php b/core/modules/outside_in/tests/modules/offcanvas_test/src/Form/OffCanvasForm.php similarity index 100% rename from core/modules/outside_in/tests/modules/offcanvas_test/src/Form/OffcanvasForm.php rename to core/modules/outside_in/tests/modules/offcanvas_test/src/Form/OffCanvasForm.php diff --git a/core/modules/outside_in/tests/src/Unit/OutsideInBlockManagerTest.php b/core/modules/outside_in/tests/src/Unit/OutsideInBlockManagerTest.php index d0f3ccc..1158516 100644 --- a/core/modules/outside_in/tests/src/Unit/OutsideInBlockManagerTest.php +++ b/core/modules/outside_in/tests/src/Unit/OutsideInBlockManagerTest.php @@ -81,6 +81,23 @@ public function testGetFormObjectUsingPlugin() { /** * @covers ::getFormObject */ + public function testGetFormObjectDefaultFallback() { + $this->classResolver->getInstanceFromDefinition(Argument::cetera())->shouldNotBeCalled(); + + $plugin = $this->prophesize(PluginInspectionInterface::class)->willImplement(PluginFormInterface::class); + $plugin->getPluginDefinition()->willReturn([ + 'form' => [ + 'default' => get_class($plugin->reveal()), + ], + ]); + + $form_object = $this->manager->getFormObject($plugin->reveal(), 'missing'); + $this->assertSame($plugin->reveal(), $form_object); + } + + /** + * @covers ::getFormObject + */ public function testGetFormObjectOperationAware() { $plugin_form = $this->prophesize(PluginFormInterface::class)->willImplement(OperationAwareFormInterface::class); $plugin_form->setOperation('operation_aware')->shouldBeCalled();