Problem/Motivation
I get an error if I remove a existing content type in my dashboard:
Error: Call to a member function getDescription() on null in Drupal\dashboards\Plugin\Dashboard\AddContentMenu->buildRenderArray() (line 86 of modules/contrib/dashboards/src/Plugin/Dashboard/AddContentMenu.php).
Ex:
Warning: Undefined array key "push_notifications" in Drupal\dashboards\Plugin\Dashboard\AddContentMenu->buildRenderArray() (line 87 of modules/contrib/dashboards/src/Plugin/Dashboard/AddContentMenu.php).
Steps to reproduce
Create a dashboard, add "Add content block", then remove a content type and try to access to your dashboard
Proposed resolution
In the controller (src/Plugin/Dashboard/addContentMenu.php) line 84, add a condition:
if(isset($types[$bundle])){ /* the condition*/
$items[] = [
'url' => Url::fromRoute('node.add', ['node_type' => $bundle]),
'title' => $bundleInfo[$bundle]['label'],
'description' => ['#markup' => $types[$bundle]->getDescription()],
];
}Thanks!
Issue fork dashboards-3334514
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
erik seifert commentedComment #5
j-vee commentedI needed a patch for this one so I opened up a MR. This one fixed the issue for us.
Comment #7
erik seifert commentedComment #8
erik seifert commented