summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-06-29 11:21:46 (GMT)
committer Alex Pott2013-06-29 11:21:46 (GMT)
commit54e9f29c5e5c54871bce98f9149c0531426d6e37 (patch)
treef7e904d6d390cf27b59bd0980b0a670c2a4534c6
parent4c357934c2bdaa3e2ce77547ca890caeb0f25d8f (diff)
Issue #1983874 by RoSk0, InternetDevels, vijaycs85, dawehner: Convert block_admin_add() in block.admin.inc to the new form interface.
-rw-r--r--core/modules/block/block.admin.inc19
-rw-r--r--core/modules/block/block.module7
-rw-r--r--core/modules/block/block.routing.yml7
-rw-r--r--core/modules/block/lib/Drupal/block/Controller/BlockAddController.php58
4 files changed, 65 insertions, 26 deletions
diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc
index af99b1a..3fde289 100644
--- a/core/modules/block/block.admin.inc
+++ b/core/modules/block/block.admin.inc
@@ -22,25 +22,6 @@ function block_admin_demo($theme = NULL) {
}
/**
- * Page callback: Build the block instance add form.
- *
- * @param string $plugin_id
- * The plugin ID for the block instance.
- * @param string $theme
- * The name of the theme for the block instance.
- *
- * @return array
- * The block instance edit form.
- */
-function block_admin_add($plugin_id, $theme) {
- $entity = entity_create('block', array(
- 'plugin' => $plugin_id,
- 'theme' => $theme,
- ));
- return Drupal::entityManager()->getForm($entity);
-}
-
-/**
* Page callback: Build the block instance edit form.
*
* @param \Drupal\block\Plugin\Core\Entity\Block $entity
diff --git a/core/modules/block/block.module b/core/modules/block/block.module
index c7b4331..321f584 100644
--- a/core/modules/block/block.module
+++ b/core/modules/block/block.module
@@ -119,13 +119,6 @@ function block_menu() {
'description' => 'Configure what block content appears in your site\'s sidebars and other regions.',
'route_name' => 'block_admin_display',
);
- $items['admin/structure/block/add/%/%'] = array(
- 'title' => 'Configure block',
- 'page callback' => 'block_admin_add',
- 'page arguments' => array(4, 5),
- 'access arguments' => array('administer blocks'),
- 'file' => 'block.admin.inc',
- );
$items['admin/structure/block/manage/%block'] = array(
'title' => 'Configure block',
'page callback' => 'block_admin_edit',
diff --git a/core/modules/block/block.routing.yml b/core/modules/block/block.routing.yml
index 635f4c2..f46ceaa 100644
--- a/core/modules/block/block.routing.yml
+++ b/core/modules/block/block.routing.yml
@@ -12,3 +12,10 @@ block_admin_display:
entity_type: 'block'
requirements:
_permission: 'administer blocks'
+
+block_admin_add:
+ pattern: '/admin/structure/block/add/{plugin_id}/{theme}'
+ defaults:
+ _content: '\Drupal\block\Controller\BlockAddController::blockAddConfigureForm'
+ requirements:
+ _permission: 'administer blocks'
diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockAddController.php b/core/modules/block/lib/Drupal/block/Controller/BlockAddController.php
new file mode 100644
index 0000000..f7f4e38
--- /dev/null
+++ b/core/modules/block/lib/Drupal/block/Controller/BlockAddController.php
@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\block\Controller\BlockAddController.
+ */
+
+namespace Drupal\block\Controller;
+
+use Drupal\Core\Controller\ControllerInterface;
+use Drupal\Core\Entity\EntityManager;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+/**
+ * Controller for building the block instance add form.
+ */
+class BlockAddController implements ControllerInterface {
+
+ /**
+ * Constructs a Block object.
+ *
+ * @param \Drupal\Core\Entity\EntityManager $entity_manager
+ * Entity manager service.
+ */
+ public function __construct(EntityManager $entity_manager) {
+ $this->entityManager = $entity_manager;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public static function create(ContainerInterface $container) {
+ return new static(
+ $container->get('plugin.manager.entity')
+ );
+ }
+
+ /**
+ * Build the block instance add form.
+ *
+ * @param string $plugin_id
+ * The plugin ID for the block instance.
+ * @param string $theme
+ * The name of the theme for the block instance.
+ *
+ * @return array
+ * The block instance edit form.
+ */
+ public function blockAddConfigureForm($plugin_id, $theme) {
+ // Set the page title.
+ drupal_set_title(t('Configure block'));
+
+ // Create a block entity.
+ $entity = $this->entityManager->getStorageController('block')->create(array('plugin' => $plugin_id, 'theme' => $theme));
+
+ return $this->entityManager->getForm($entity);
+ }
+}