|
| 1 | +# Migrating from WoltLab Suite 6.2 - PHP |
| 2 | + |
| 3 | +## Category List Pages |
| 4 | + |
| 5 | +The legacy category list pages based on `AbstractCategoryListPage` have been replaced by [Node Tree Views](../../php/api/node_tree_views.md). |
| 6 | +The new implementation renders the categories using `CategoryNodeTreeView` and integrates with the [Interactions](../../php/api/interactions.md) system, which provides drag and drop sorting, an interaction context menu and inline quick interactions out of the box. |
| 7 | + |
| 8 | +To migrate an existing category list page to the new infrastructure, the following steps are required. |
| 9 | + |
| 10 | +### Extend `AbstractCategoryNodeTreeViewPage` |
| 11 | + |
| 12 | +Change the parent class of the list page from `AbstractCategoryListPage` to `AbstractCategoryNodeTreeViewPage` and update the type declaration of `$objectTypeName` from untyped to `string`: |
| 13 | + |
| 14 | +```php |
| 15 | +class ArticleCategoryListPage extends AbstractCategoryNodeTreeViewPage |
| 16 | +{ |
| 17 | + public $activeMenuItem = 'wcf.acp.menu.link.article.category.list'; |
| 18 | + |
| 19 | + public string $objectTypeName = 'com.woltlab.wcf.article.category'; |
| 20 | +} |
| 21 | +``` |
| 22 | + |
| 23 | +The previously used template, action handlers and read methods are no longer required and can be removed. |
| 24 | +`AbstractCategoryNodeTreeViewPage` uses the `categoryNodeTreeView` template and creates the matching `CategoryNodeTreeView` instance automatically. |
| 25 | + |
| 26 | +### Implement `getEditControllerClass()` and `getAddControllerClass()` |
| 27 | + |
| 28 | +Two new methods have been added to `ICategoryType`: |
| 29 | + |
| 30 | +- `getEditControllerClass(): string` returns the class name of the controller used to edit categories of this type. |
| 31 | +- `getAddControllerClass(): string` returns the class name of the controller used to add categories of this type. |
| 32 | + |
| 33 | +Both methods must be implemented by every concrete category type so that the node tree view and the interactions can link to the correct edit and add forms. |
| 34 | + |
| 35 | +```php |
| 36 | +class ArticleCategoryType extends AbstractCategoryType |
| 37 | +{ |
| 38 | + #[\Override] |
| 39 | + public function getEditControllerClass(): string |
| 40 | + { |
| 41 | + return ArticleCategoryEditForm::class; |
| 42 | + } |
| 43 | + |
| 44 | + #[\Override] |
| 45 | + public function getAddControllerClass(): string |
| 46 | + { |
| 47 | + return ArticleCategoryAddForm::class; |
| 48 | + } |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +`AbstractCategoryType` provides empty default implementations to avoid breaking existing third-party category types. Categories of types that do not provide these methods will not be editable through the node tree view. |
| 53 | + |
| 54 | +### Pre-Selecting the Parent Category in the Add Form |
| 55 | + |
| 56 | +`CategoryAddFormBuilderForm` now reads the optional `parentCategoryID` GET parameter and pre-selects the corresponding parent category in the add form. |
| 57 | +This is used by the “Add Child Category” interaction in the node tree view to allow users to directly create a child category for a given node. |
| 58 | + |
| 59 | +Custom subclasses of `CategoryAddFormBuilderForm` do not require any changes for this to work. |
0 commit comments