This is a live step-by-step tutorial of my process of porting pathinfo module form Drupal 7.x to Drupal 8.x as part of the global sprint weekend, March 9th-10th, 2013.
The commit of Drupal 8 I was working against is:
* 957b556 - (HEAD, origin/HEAD, origin/8.x, 8.x) Issue #1932596 by ACF: Change site_name() into config in userpasswordreset.test and formtest. (4 hours ago)
I installed a copy of Drupal 8 locally to test against. With that done:
- Start a new branch of my module:
$ git checkout -b 8.x-1.x
- On my first push, create a new upstream branch
git push --set-upstream origin 8.x-1.x
- Create a development release
Steps to upgrade
|Can't enable module.||.info files are now .info.yml files||Rename file and change to YAML format.||1241617|
|Using variable_* functions instead of CMI.||Site information variables converted to config system||How to upgrade variables into configuration||efbe1eb|
|Config form doesn't change variables stored via CMI.||system_settings_form() deprecated in favour of system_config_form() or \Drupal\system\SystemConfigFormBase||Refactor form to use system_config_form().||b4c2b57|
|Config form implemented procedurally.||While I used system_config_form() above, the preferred method is to extend \Drupal\system\SystemConfigFormBase.||Refactor form to be implemented via a routing.yml, and a controller class.||e9c4566|
|Some paths (like admin/structure/views) are not parsed correctly by pathinfo.||New Symfony-based routing system||Use "request" and "controller_resolver" Drupal services to find callback.||Can't get this to work. Pattern is
There's some issue with multiple requests on one page load. Will come back to this.
|I want to use the new theming system, Twig.||Completely new theme/template system: Twig||Create a
- Use the Drupal 8 change records as your reference when upgrading.
- Now that Drupal runs on top of Symfony, a lot of core functionality is provided by services, which are managed by a Symfony Service Container. You can read about that in more detail in Change Notice: Use Dependency Injection to handle global PHP objects.
- The root Drupal class has a static method to help you access available services: Drupal::service()
- A handy way to see which services are available is
I have to admit, somewhat embarassingly, that the module worked almost perfectly after my first commit above. Drupal 8 still has many Drupal 7 API calls intact, but I wanted to upgrade it to use D8 paradigms, so I kept going.