Commit 54e9f29c authored by alexpott's avatar alexpott

Issue #1983874 by RoSk0, InternetDevels, vijaycs85, dawehner: Convert...

Issue #1983874 by RoSk0, InternetDevels, vijaycs85, dawehner: Convert block_admin_add() in block.admin.inc to the new form interface.
parent 4c357934
......@@ -21,25 +21,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.
*
......
......@@ -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',
......
......@@ -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'
<?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);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment