diff --git a/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php b/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php
index 2e5c872..e9aaab2 100644
--- a/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php
+++ b/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php
@@ -94,18 +94,7 @@ protected function getFormObject(Request $request, $form_arg, $_values = FALSE)
$defaults_class = new $class();
}
- // Using reflection, find all of the parameters needed by the form in
- // the request attributes.
- $attributes = $request->attributes->all();
- $reflection = new \ReflectionMethod($class, $method);
- $params = $reflection->getParameters();
- $args = array();
- foreach ($params as $param) {
- if (array_key_exists($param->name, $attributes)) {
- $args[] = $attributes[$param->name];
- }
- }
- $values = call_user_func_array(array($defaults_class, $method), $args);
+ $values = call_user_func(array($defaults_class, $method), $request);
}
$entity = $manager->getStorageController($entity_type)->create($values);
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php
index 1b4345a..dcc241c 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php
@@ -82,7 +82,7 @@ public function add() {
/**
* Presents the custom block creation form.
*
- * @param Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $custom_block_type
+ * @param \Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $custom_block_type
* The custom block type to add.
*
* @return array
@@ -106,13 +106,14 @@ protected function addForm(CustomBlockType $custom_block_type) {
/**
* Returns default values for the new entity.
*
- * @param Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $custom_block_type
- * The custom block type to add.
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * The current request.
*
* @return array
* Array of default values to use whilst creating entity form.
*/
- public function defaults(CustomBlockType $custom_block_type) {
+ public function defaults(Request $request) {
+ $custom_block_type = $request->attributes->get('custom_block_type');
return array(
'type' => $custom_block_type->id()
);