So it took a few hours of reading, writing, testing, breaking and fixing in order to upgrade the js_injector module to Drupal 8, but all in all, it was a positive experience. It would be worth reading this tutorial for more information on how to upgrade your code. $config->set('site_name', 'My Awesome Site') $config = config('core.site_information') The above code would therefore change as follows: // Load the site name out of configuration. In Drupal 8, configuration will only be lazy-loaded when needed. Variable_set('site_name', 'This is the dev site.') Change the site name to something else. $site_name = variable_get('site_name', 'Drupal') In Drupal 7, all variables are global, so accessing and saving them is done this way: // Load the site name out of configuration. For more information see the change request. The PHP super global key $_GET is 100% missing in Drupal 8, now you are forced to use the standard method current_path(). I actually like this change from Drupal here, as all to often contributed modules like to do silly expensive things within hook_init() not realising in Drupal 7 they fire on every page request. I was wondering why this hook was not firing, turns out this was removed recently - I was able to replace it instead with hook_page_build(). Similarly you can also add HTTP requirements to each end point.įor more information see the change request and the Symfony documentation. It is now possible to overload path placeholders and have one that listens for an integer, and another that is listening for a string. The new Symfony routing components extend what was impossible with plain 'ol hook_menu() in Drupal 7. Pattern: '/admin/config/development/js-injector' New route information (in file js_): js_injector_rule_admin: 'route_name' => 'js_injector_rule_admin', 'description' => 'Add and modify JavaScript injector rules.', None, this was handled entirely by ctools exportables. Hook_menu() is still there, but now with Symfony routes integration
0 Comments
Leave a Reply. |