Skip to main content
Bumped by Community user
Improves post formatting.
Link
kenorb
  • 14.3k
  • 10
  • 100
  • 170

I can't programmatically Can't render a block due to recoverable fatal error

removed "Drupal" from the title; removed tags from the title
Source Link
avpaderno
  • 98.1k
  • 15
  • 165
  • 284

Can't I can't programmatically render a block by programmatically when update core to 8.2.x

I had code to programmatically render a block by programmatically.

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

That code working for major Drupal 8.1.x when updateAfter updating to Drupal 8.2.x had show, I get the following error:

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

What's solution forHow do I fix this error?

Thanks

Can't render block by programmatically when update core to 8.2.x

I had code to render block by programmatically

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

That code working for major Drupal 8.1.x when update to 8.2.x had show error:

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

What's solution for fix ?

Thanks

I can't programmatically render a block

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?

Source Link
Henry Tran
  • 173
  • 1
  • 2
  • 11

Can't render block by programmatically when update core to 8.2.x

I had code to render block by programmatically

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

That code working for major Drupal 8.1.x when update to 8.2.x had show error:

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

What's solution for fix ?

Thanks