Issue #2124599 by olli, tedbow, swentel: ode_block_access affects access to editing blocks Removes 'operations' links for Block layout page.

8.0.x
catch 2014-03-28 14:51:56 +01:00
parent fee6ae0e0f
commit 6a4ba9df64
2 changed files with 12 additions and 2 deletions

View File

@ -153,6 +153,11 @@ class NodeBlockFunctionalTest extends NodeTestBase {
$this->assertText($label, 'Block was displayed on the node/N when node is of type article.');
$this->drupalGet('node/' . $node5->id());
$this->assertNoText($label, 'Block was not displayed on nodes of type page.');
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/structure/block');
$this->assertText($label, 'Block was displayed on the admin/structure/block page.');
$this->assertLinkByHref(url('admin/structure/block/manage/' . $block->id()));
}
}

View File

@ -8,7 +8,6 @@
* API pattern.
*/
use Drupal\Component\Utility\String;
use Drupal\Core\Language\Language;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Cache\Cache;
@ -23,6 +22,8 @@ use Drupal\Core\Template\Attribute;
use Drupal\file\Entity\File;
use Drupal\language\Entity\Language as LanguageEntity;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Drupal\block\Entity\Block;
use Drupal\Core\Session\AccountInterface;
/**
* Denotes that the node is not published.
@ -1075,7 +1076,11 @@ function node_form_block_form_alter(&$form, &$form_state) {
* Checks the content type specific visibility settings and removes the block
* if the visibility conditions are not met.
*/
function node_block_access($block) {
function node_block_access(Block $block, $operation, AccountInterface $account, $langcode) {
// Only affect access when viewing the block.
if ($operation != 'view') {
return;
}
$visibility = $block->get('visibility');
if (!empty($visibility)) {
if (!empty($visibility['node_type']['types'])) {