diff --git a/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php b/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php index df53372..41133e8 100644 --- a/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php +++ b/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Entity; -use Symfony\Component\HttpFoundation\Response; use Drupal\Core\Controller\HtmlFormController; use Symfony\Component\HttpFoundation\Request; @@ -16,7 +15,6 @@ */ class HtmlEntityFormController extends HtmlFormController { - /** * {@inheritdoc} * @@ -59,10 +57,9 @@ protected function getFormObject(Request $request, $form_arg) { } else { $values = array(); - // A default values callback has been provided. - if (($_values = $request->attributes->get('_values')) && - // Callable is in format class::method. - strpos($_values, '::') !== FALSE) { + // A default values callback has been provided and the callable is in + // class::method format. + if (($_values = $request->attributes->get('_values')) && strpos($_values, '::') !== FALSE) { // Extract the class and method from the given string. list($class, $method) = explode('::', $_values); // The default values callback is in a ControllerInterface object. 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 dcc241c..76e260f 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 @@ -9,7 +9,7 @@ use Drupal\Core\ControllerInterface; use Drupal\Core\Entity\EntityManager; -use Drupal\custom_block\Plugin\Core\Entity\CustomBlockType; +use Drupal\custom_block\Plugin\Core\Entity\CustomBlockTypeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -73,37 +73,25 @@ public function add() { $types = $this->entityManager->getStorageController('custom_block_type')->load(); if ($types && count($types) == 1) { $type = reset($types); - return $this->addForm($type); + $block = $this->entityManager->getStorageController('custom_block')->create(array( + 'type' => $custom_block_type->id() + )); + $options = array(); + if (($theme = $this->request->attributes->get('theme')) && in_array($theme, array_keys(list_themes()))) { + // We have navigated to this page from the block library and will keep track + // of the theme for redirecting the user to the configuration page for the + // newly created block in the given theme. + $block->setTheme($theme); + } + // @todo remove call to entity_get_form() when + // http://drupal.org/node/1982980 is in. + return entity_get_form($block); } return array('#theme' => 'custom_block_add_list', '#content' => $types); } /** - * Presents the custom block creation form. - * - * @param \Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $custom_block_type - * The custom block type to add. - * - * @return array - * A form array as expected by drupal_render(). - */ - protected function addForm(CustomBlockType $custom_block_type) { - $block = $this->entityManager->getStorageController('custom_block')->create(array( - 'type' => $custom_block_type->id() - )); - $options = array(); - if (($theme = $this->request->attributes->get('theme')) && in_array($theme, array_keys(list_themes()))) { - // We have navigated to this page from the block library and will keep track - // of the theme for redirecting the user to the configuration page for the - // newly created block in the given theme. - $block->setTheme($theme); - } - return entity_get_form($block); - } - - - /** * Returns default values for the new entity. * * @param \Symfony\Component\HttpFoundation\Request $request