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

Command icon 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

julian_esimaginacion created an issue. See original summary.

erik seifert’s picture

Assigned: Unassigned » erik seifert

j-vee made their first commit to this issue’s fork.

j-vee’s picture

Status: Active » Needs review

I needed a patch for this one so I opened up a MR. This one fixed the issue for us.

erik seifert’s picture

Status: Needs review » Fixed
erik seifert’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.