Skip to content
Snippets Groups Projects
Commit 36cfe009 authored by bonrita's avatar bonrita Committed by Joshua Sedler
Browse files

Issue #3012844 by bonrita, Grevil: Exception when pre-added view block is deleted

parent 0c0715e9
Branches
Tags 2.2.0
1 merge request!5Issue #3264557: Plan for 2.0.0-alpha1 bugfix release
......@@ -2,6 +2,7 @@
namespace Drupal\homebox\Form;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Core\Block\BlockManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Theme\ThemeManagerInterface;
......@@ -208,14 +209,28 @@ class HomeboxSettingsForm extends EntityForm {
}
foreach ($homebox_blocks as $block) {
$definition = $this->blockManager->getDefinition($block['id']);
$blocks[$block['region']][$block['id']] = [
'label' => $definition['admin_label'],
'entity_id' => $block['id'],
'entity' => NULL,
'category' => $definition['category'],
'status' => $block['status'],
];
try {
$definition = $this->blockManager->getDefinition($block['id']);
$blocks[$block['region']][$block['id']] = [
'label' => $definition['admin_label'],
'entity_id' => $block['id'],
'entity' => NULL,
'category' => $definition['category'],
'status' => $block['status'],
];
}
catch (PluginNotFoundException $e) {
$this->logger('homebox')->notice('A block does not exist anymore! Please go to the location of this message and remove it!');
$this->messenger()->addError('There seems to be a broken block! Please remove it or enable the module, which provides this block.');
$blocks[$block['region']][$block['id']] = [
'label' => $this->t('THIS BLOCK IS BROKEN! PLEASE REMOVE IT!.'),
'entity_id' => $block['id'],
'entity' => NULL,
'category' => $this->t('Broken'),
'status' => $block['status'],
];
}
if (isset($block['weight'])) {
$blocks[$block['region']][$block['id']]['weight'] = $block['weight'];
}
......@@ -478,8 +493,7 @@ class HomeboxSettingsForm extends EntityForm {
['query' => ['block-enable' => $block_id]]
),
];
}
else {
} else {
$operations['disable'] = [
'title' => t('Disable'),
'weight' => 40,
......@@ -543,5 +557,4 @@ class HomeboxSettingsForm extends EntityForm {
}
return $this->theme;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment