Since version 6.0 TYPO3 offers an API to make the use of categories in own extensions possible with little effort.
To activate the categories for a model of your own extension or an existing extension, the following code must be added to the corresponding file in the directory Configuration/TCA/Overrides/ of the extension. Please always put this code in the overrides and not in the TCA/file.
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable( 'my_ext', 'tx_myext_domain_model_example', 'categories' // this parameter is optional! default value is categories );
In the first parameter we pass the extension key. Second, the table name of the model. The following additional parameters can be added as an option: Third parameter: Field name in the model table for categories. Fourth parameter: Optional configuration. Fifth parameter: Overwrite and delete old configuration.
After adding the code, a Database Compare must be performed using the Install Tool or alternatively the extension must be deactivated and reactivated using the Extension Manager to add the new field.