Hello everyone,

I am converting a simple contrib module (https://drupal.org/project/fb_likebox) that uses Facebook API to display a Like Box into a Drupal Block from Drupal 7 to Drupal 8 (full code at http://drupalcode.org/project/fb_likebox.git/tree/refs/heads/8.x-1.x)
I would like to use the new Twig template system, and I am having some problems in the build() function to locate the proper file.

The build function looks as follows:

/**
* Implements \Drupal\block\BlockBase::build().
*/
public function build() {
   return array(
      '#children' => theme('fb_likebox_block'),
       );
   }
}

(Full code at: http://drupalcode.org/project/fb_likebox.git/blob/refs/heads/8.x-1.x:/li...)

The log displays the following error:
Theme hook fb_likebox_block not found.

I placed the template in templates/fb_likebox_block.html.twig (Full code at http://drupalcode.org/project/fb_likebox.git/blob/refs/heads/8.x-1.x:/te...)

I have been going through some examples (who's online block of "user" or "pants"), and the structure seems similar.

Does anyone have any clue why the template file is not being found?

Thanks a lot,

David

Comments

I was missing a theme function in .module, I thought it was necessary anymore:

/**
* Implements hook_theme().
*/
function fb_likebox_theme() {
  return array(
      'fb_likebox_block' => array(
          'variables' => array(),
          'template' => 'fb_likebox_block'
      ),
  );
}

I share this in case it can be useful for someone else