Skip to main content
3 of 3
Improves post formatting.
kenorb
  • 14.3k
  • 10
  • 100
  • 170

Can't render a block due to recoverable fatal error

I had code to programmatically render a block.

$block = \Drupal\block\Entity\Block::load('bartik_search'); $block_content = \Drupal::entityManager() ->getViewBuilder('block') ->view($block); return array('#markup' => drupal_render($block_content)); 

After updating to Drupal 8.2.x, I get the following error:

Recoverable fatal error: Argument 1 passed to Drupal\block\BlockViewBuilder::view() must implement interface

How do I fix this error?

Henry Tran
  • 173
  • 1
  • 2
  • 11