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) {
);
}
/**
* 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() {
);
$items['admin/structure/block/manage/%block'] = array(
'title' => 'Configure block',
'page callback' => 'block_admin_edit',
'page arguments' => array(4),
'access arguments' => array('administer blocks'),
'file' => 'block.admin.inc',
'route_name' => 'block_admin_edit',
);
$items['admin/structure/block/manage/%block/configure'] = array(
'title' => 'Configure block',
......
......@@ -5,6 +5,13 @@ block_admin_block_delete:
requirements:
_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:
pattern: '/admin/structure/block'
defaults:
......
......@@ -20,9 +20,8 @@ class BlockAccessController extends EntityAccessController {
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
// Currently, only view access is implemented.
if ($operation != 'view') {
return FALSE;
return user_access('administer blocks', $account);
}
// Deny access to disabled blocks.
......
......@@ -242,7 +242,7 @@ public function buildForm(array $form, array &$form_state) {
);
$links['configure'] = array(
'title' => t('configure'),
'href' => 'admin/structure/block/manage/' . $entity_id . '/configure',
'href' => 'admin/structure/block/manage/' . $entity_id,
);
$links['delete'] = array(
'title' => t('delete'),
......
......@@ -161,7 +161,7 @@ function testHideBlockTitle() {
$edit = array(
'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->drupalGet('user');
......
......@@ -82,7 +82,7 @@ function testAccessDenied() {
$edit = array(
'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.
$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