diff -u b/core/modules/block/src/BlockListBuilder.php b/core/modules/block/src/BlockListBuilder.php --- b/core/modules/block/src/BlockListBuilder.php +++ b/core/modules/block/src/BlockListBuilder.php @@ -366,6 +366,27 @@ if (isset($operations['delete'])) { $operations['delete']['title'] = $this->t('Remove'); } + + if ($entity instanceof BlockOperationsProviderInterface) { + $operations += $entity->getOperationLinks(); + } + + foreach ($operations as $key => $operation) { + // Don't add destination to default operation links. + if (!in_array($key, ['edit', 'disable', 'delete'])) { + if ($operation['url']->getOption('query')) { + $operation['url']->mergeOptions([ + 'query', + ['destination' => 'admin/structure/block'], + ]); + } + else { + $operation['url']->setOption('query', ['destination' => 'admin/structure/block']); + } + $operations[$key] = $operation; + } + } + return $operations; } @@ -397,46 +418,4 @@ /** - * Builds a renderable list of operation links for the entity. - * - * @param \Drupal\Core\Entity\EntityInterface $entity - * The entity on which the linked operations will be performed. - * - * @return array - * A renderable array of operation links. - * - * @see \Drupal\Core\Entity\EntityListBuilder::buildRow() - */ - public function buildOperations(EntityInterface $entity) { - $build = [ - '#type' => 'operations', - '#links' => $this->getOperations($entity), - ]; - - if ($entity instanceof BlockOperationsProviderInterface) { - $build['#links'] += $entity->getOperationLinks(); - } - - if (is_array($build['#links'])) { - foreach ($build['#links'] as $key => $operation) { - // Don't add destination to default operation links. - if (!in_array($key, ['edit', 'disable', 'delete'])) { - if ($operation['url']->getOption('query')) { - $operation['url']->mergeOptions([ - 'query', - ['destination' => 'admin/structure/block'], - ]); - } - else { - $operation['url']->setOption('query', ['destination' => 'admin/structure/block']); - } - $build['#links'][$key] = $operation; - } - } - } - - return $build; - } - - /** * Wraps system_region_list(). */