I am building a custom module for Drupal 8.4.4 and is not detecting the hook_theme from a block. I get an error message saying "Theme hook gardentheme not found". If I uninstall the module and install it again, it works fine, but as soon as I clear the cache, it doesn't find the theme_hook anymore.
I notice that die() and exit; wont do anything on my .module file after clearing the cache, I feel as after clearing the cache the .module is not run anymore.
My module file called garden.module
<?php
/**
* @file
*
*/
/**
* Implements hook_theme()
*/
function garden_theme($existing, $type, $theme, $path){
return array('gardentheme' =>
array(
'variables' => array(
'description' => NULL
),
)
);
}
My block placed on src/Plugin/Block/GardenScheduleBlock.php
<?php
namespace Drupal\garden\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides a 'GardenSchedule' Block.
*
* @Block(
* id = "garden_schedule_block",
* admin_label = @Translation("Garden Schedule"),
* category = @Translation("Garden Schedule_Category"),
* )
*/
class GardenScheduleBlock extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
return array(
'#theme' => 'gardentheme',
'#description' => "description test"
);
}
}
Thanks in advance for any tips.
core/rebuild.php
- make sure to enable it in your settings/local.settings file -$settings['rebuild_access'] = TRUE;
Does this help you at all? I'm not sure how this differs from drush cr / manual cache rebuild in admin though. The docs state "Rebuilds all Drupal caches even when Drupal itself does not work." api.drupal.org/api/drupal/core%21rebuild.php/8.1.x – user2307706