I'm upgrading the Custom Search module which overrides the core Search module.
In order to customize the search result, I'm using hook_theme to register 'search_result'.
In D7, my module weight was set so it was run after the core Search hook_theme function.
In D8, my module weight is still set to run after core Search, but my hook_theme is run before it (seems to be run alphabetically, and Custom Search comes before Search), so it's useless now… core Search overrides my functions.

Comments

Berdir’s picture

\Drupal\Core\Theme\Registry::build() uses getImplementations() like everything else. Are you sure that you are setting the weight correctly?

What does drush ev "var_dump(\Drupal::moduleHandler()->getImplementations('theme'))" print?

Maybe it is merged differently?

jdanthinne’s picture

Module weight is set by module_set_weight('custom_search', 10); in custom_search_install() function inside custom_search.install file.

var_dump gives the following (seems alphabetical to me):

array(25) {
  [0]=>
  string(5) "block"
  [1]=>
  string(13) "block_content"
  [2]=>
  string(8) "ckeditor"
  [3]=>
  string(5) "color"
  [4]=>
  string(7) "comment"
  [5]=>
  string(18) "config_translation"
  [6]=>
  string(13) "custom_search"
  [7]=>
  string(5) "devel"
  [8]=>
  string(8) "field_ui"
  [9]=>
  string(4) "file"
  [10]=>
  string(6) "filter"
  [11]=>
  string(5) "image"
  [12]=>
  string(8) "language"
  [13]=>
  string(6) "locale"
  [14]=>
  string(7) "menu_ui"
  [15]=>
  string(4) "node"
  [16]=>
  string(3) "rdf"
  [17]=>
  string(6) "search"
  [18]=>
  string(6) "system"
  [19]=>
  string(8) "taxonomy"
  [20]=>
  string(7) "toolbar"
  [21]=>
  string(6) "update"
  [22]=>
  string(4) "user"
  [23]=>
  string(8) "views_ui"
  [24]=>
  string(5) "views"
}
joelpittet’s picture

Version: 8.0.0-beta2 » 8.0.x-dev

@jdanthinne just stumbled on this. Not sure where the weight gets stored in D8 yet. I can reproduce on 8.0.x-dev so I'm moving to that so it doesn't get lost.

DuaelFr’s picture

Issue tags: +HappyDays1506
jhedstrom’s picture

Status: Active » Closed (works as designed)

I think this is working now:

drush ev "module_set_weight('system', -50);"
drush cr
drush ev "var_dump(\Drupal::moduleHandler()->getImplementations('theme'))"
array(21) {
  [0] =>
  string(6) "system"
  [1] =>
  string(5) "block"
  [2] =>
  string(13) "block_content"
  [3] =>
  string(8) "ckeditor"
  [4] =>
  string(5) "color"
  [5] =>
  string(7) "comment"
  [6] =>
  string(8) "field_ui"
  [7] =>
  string(4) "file"
  [8] =>
  string(6) "filter"
  [9] =>
  string(5) "image"
  [10] =>
  string(4) "link"
  [11] =>
  string(4) "node"
  [12] =>
  string(3) "rdf"
  [13] =>
  string(6) "search"
  [14] =>
  string(10) "simpletest"
  [15] =>
  string(8) "taxonomy"
  [16] =>
  string(7) "toolbar"
  [17] =>
  string(6) "update"
  [18] =>
  string(4) "user"
  [19] =>
  string(8) "views_ui"
  [20] =>
  string(5) "views"
}