Skip to content

XELOS Module Refactoring

Since XELOS 8 there are many changes made to the structure and namings. Actually the version 8 supports the old and the new convention. Due the old convention support is limited for the next major releases, old modules should be refactored to the new conventions.

How to refactor an old module to XELOS 8

The refactoring procedure starts with pulling all classes in the module namespace, rename the classes and check variable scopes afterwards.

Use the following procedure in PHPStorm on every file in your module:

  1. Open the file, right click on the class name and choose "Refactor -> Move" (Move class into namespace "F6"). Please note that the directory is correct. Make sure you check the proposed refactoring and confirm the refactoring (all files referring to your class will be changed automatically).
  2. Rename the class by right clicking and selecting "Refactor -> Rename". Trigger the advanced dialog by repeating the same click again (or hit the displayed shortcut "SHIFT+F6"). Refer to the section below for renaming the classes - for correct refactoring you might need to be forced to move some files into new directories (e.g. hooks).
  3. Rename / Move the file to reflect new classname and namespace according the PSR conventions.
  4. Update all references to use current namespaces (e.g. xelos_controller becomes \XELOS\Framework\Module\Controller), you should follow all(!) advices in your IDE. Common mistakes are "Exception" instead of "\Exception", "xf::instance()" instead of "XF::instance()"

Renaming Classes (Quicksheet)

Please check code conventions for more details.

  • main.class.php / xm_my_module => MyModuleController.php / XELOS\Modules\MyModule\MyModuleController
  • xaction_example.class.php => ../Action/ExampleAction.php
  • xmodel_example.class.php => ../Model/Example.php