Commit b6556573 authored by catch's avatar catch

Issue #1981144 by kgoel, tim.plunkett, disasm, vijaycs85, naxoc, stella,...

Issue #1981144 by kgoel, tim.plunkett, disasm, vijaycs85, naxoc, stella, dawehner: Convert block_admin_edit() in block.admin.inc to the new form interface.
parent 419d1d9b
...@@ -21,32 +21,3 @@ function block_admin_demo($theme = NULL) { ...@@ -21,32 +21,3 @@ function block_admin_demo($theme = NULL) {
); );
} }
/**
* Page callback: Build the block instance edit form.
*
* @param \Drupal\block\Plugin\Core\Entity\Block $entity
* The block instance.
*
* @return array
* The block instance edit form.
*/
function block_admin_edit(Block $entity) {
// Get the theme for the page title.
$admin_theme = config('system.theme')->get('admin');
$themes = list_themes();
$theme_key = $entity->get('theme');
$theme = $themes[$theme_key];
// Use meaningful titles for the main site and administrative themes.
$theme_title = $theme->info['name'];
if ($theme_key == config('system.theme')->get('default')) {
$theme_title = t('!theme (default theme)', array('!theme' => $theme_title));
}
elseif ($admin_theme && $theme_key == $admin_theme) {
$theme_title = t('!theme (administration theme)', array('!theme' => $theme_title));
}
// Get the block label for the page title.
drupal_set_title(t("Configure %label block in %theme", array('%label' => $entity->label(), '%theme' => $theme_title)), PASS_THROUGH);
return Drupal::entityManager()->getForm($entity);
}
...@@ -117,10 +117,7 @@ function block_menu() { ...@@ -117,10 +117,7 @@ function block_menu() {
); );
$items['admin/structure/block/manage/%block'] = array( $items['admin/structure/block/manage/%block'] = array(
'title' => 'Configure block', 'title' => 'Configure block',
'page callback' => 'block_admin_edit', 'route_name' => 'block_admin_edit',
'page arguments' => array(4),
'access arguments' => array('administer blocks'),
'file' => 'block.admin.inc',
); );
$items['admin/structure/block/manage/%block/configure'] = array( $items['admin/structure/block/manage/%block/configure'] = array(
'title' => 'Configure block', 'title' => 'Configure block',
......
...@@ -5,6 +5,13 @@ block_admin_block_delete: ...@@ -5,6 +5,13 @@ block_admin_block_delete:
requirements: requirements:
_permission: 'administer blocks' _permission: 'administer blocks'
block_admin_edit:
pattern: '/admin/structure/block/manage/{block}'
defaults:
_entity_form: 'block.default'
requirements:
_entity_access: 'block.update'
block_admin_display: block_admin_display:
pattern: '/admin/structure/block' pattern: '/admin/structure/block'
defaults: defaults:
......
...@@ -20,9 +20,8 @@ class BlockAccessController extends EntityAccessController { ...@@ -20,9 +20,8 @@ class BlockAccessController extends EntityAccessController {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
// Currently, only view access is implemented.
if ($operation != 'view') { if ($operation != 'view') {
return FALSE; return user_access('administer blocks', $account);
} }
// Deny access to disabled blocks. // Deny access to disabled blocks.
......
...@@ -242,7 +242,7 @@ public function buildForm(array $form, array &$form_state) { ...@@ -242,7 +242,7 @@ public function buildForm(array $form, array &$form_state) {
); );
$links['configure'] = array( $links['configure'] = array(
'title' => t('configure'), 'title' => t('configure'),
'href' => 'admin/structure/block/manage/' . $entity_id . '/configure', 'href' => 'admin/structure/block/manage/' . $entity_id,
); );
$links['delete'] = array( $links['delete'] = array(
'title' => t('delete'), 'title' => t('delete'),
......
...@@ -161,7 +161,7 @@ function testHideBlockTitle() { ...@@ -161,7 +161,7 @@ function testHideBlockTitle() {
$edit = array( $edit = array(
'settings[label_display]' => FALSE, 'settings[label_display]' => FALSE,
); );
$this->drupalPost('admin/structure/block/manage/' . $default_theme . '.' . $machine_name . '/configure', $edit, t('Save block')); $this->drupalPost('admin/structure/block/manage/' . $default_theme . '.' . $machine_name, $edit, t('Save block'));
$this->assertText('The block configuration has been saved.', 'Block was saved'); $this->assertText('The block configuration has been saved.', 'Block was saved');
$this->drupalGet('user'); $this->drupalGet('user');
......
...@@ -82,7 +82,7 @@ function testAccessDenied() { ...@@ -82,7 +82,7 @@ function testAccessDenied() {
$edit = array( $edit = array(
'region' => -1, 'region' => -1,
); );
$this->drupalPost('admin/structure/block/manage/stark.login/configure', $edit, t('Save block')); $this->drupalPost('admin/structure/block/manage/stark.login', $edit, t('Save block'));
// Check that we can log in from the 403 page. // Check that we can log in from the 403 page.
$this->drupalLogout(); $this->drupalLogout();
......
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