diff -u b/core/modules/block/lib/Drupal/block/BlockRenderController.php b/core/modules/block/lib/Drupal/block/BlockRenderController.php --- b/core/modules/block/lib/Drupal/block/BlockRenderController.php +++ b/core/modules/block/lib/Drupal/block/BlockRenderController.php @@ -78,14 +78,12 @@ } $build[$entity_id]['content'] = $content; - // Valid PHP function names cannot contain hyphens. - $id = str_replace(':', '__', $entity->get('plugin')); - $id = str_replace('-', '_', $id); - list(, $name) = explode('.', $entity->id()); - $name = str_replace('-', '_', $name); + // Valid PHP function names cannot contain hyphens or colons. + $plugin = str_replace(array(':', '-'), array('__', '_'), $entity->get('plugin')); + $name = str_replace('-', '_', $entity->get('name')); // All blocks, even when empty, should be available for altering. - drupal_alter(array('block_view', "block_view_$id", "block_view_$name"), $build[$entity_id], $entity); + drupal_alter(array('block_view', "block_view_$plugin", "block_view_$name"), $build[$entity_id], $entity); } return $build; diff -u b/core/modules/block/lib/Drupal/block/Tests/BlockViewAlterTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockViewAlterTest.php --- b/core/modules/block/lib/Drupal/block/Tests/BlockViewAlterTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockViewAlterTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains Drupal\block\Tests\BlockViewAlterTest. + * Contains \Drupal\block\Tests\BlockViewAlterTest. */ namespace Drupal\block\Tests; only in patch2: unchanged: --- a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php @@ -170,6 +170,9 @@ public function get($property_name, $langcode = NULL) { if ($property_name == 'theme' && !$value) { list($value) = explode('.', $this->id()); } + if ($property_name == 'name' && !$value) { + list(, $value) = explode('.', $this->id()); + } return $value; }