Commit 53ecd5da authored by Fran Garcia-Linares's avatar Fran Garcia-Linares Committed by Colan Schwartz
Browse files

Issue #3070414 by fjgarlin, vensires, bachbach: With no blocks, clicking on...

Issue #3070414 by fjgarlin, vensires, bachbach: With no blocks, clicking on the Custom Blocks tab crashes site
parent 43096322
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\structure_sync\Form;

use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\ConfigFormBase;
@@ -87,8 +88,15 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    ];

    $blockList = [];
    $blocks = $this->entityTypeManager->getStorage('block_content')
    try {
      $blocks = $this->entityTypeManager
        ->getStorage('block_content')
        ->loadMultiple();
    }
    catch (PluginNotFoundException $e) {
      $blocks = [];
    }

    foreach ($blocks as $block) {
      $blockList[$block->uuid()] = $block->info->getValue()[0]['value'];
    }