For my TYPO3 Extension sf_event_mgt I also provide a small demo extension, which shows how to extend domain models and controllers of the main extension. The previous version using config.tx_extbase.objects can be found here. I migrated this demo extension to use XCLASSes instead.
The code below shows, how two models and one controller are extended using XLASS
// XCLASS event
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\DERHANSEN\SfEventMgt\Domain\Model\Event::class] = [
'className' => \DERHANSEN\SfEventMgtExtendDemo\Domain\Model\Event::class
];
// Register extended domain class
GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class)
->registerImplementation(
\DERHANSEN\SfEventMgt\Domain\Model\Event::class,
\DERHANSEN\SfEventMgtExtendDemo\Domain\Model\Event::class
);
// XCLASS registration
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\DERHANSEN\SfEventMgt\Domain\Model\Registration::class] = [
'className' => \DERHANSEN\SfEventMgtExtendDemo\Domain\Model\Registration::class
];
// Register extended registration class
GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class)
->registerImplementation(
\DERHANSEN\SfEventMgt\Domain\Model\Registration::class,
\DERHANSEN\SfEventMgtExtendDemo\Domain\Model\Registration::class
);
// XCLASS EventController
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\DERHANSEN\SfEventMgt\Controller\EventController::class] = [
'className' => \DERHANSEN\SfEventMgtExtendDemo\Controller\EventController::class
];
For domain models, the important part is the registerImplementation() call, since this instructs Extbase to use the extended domain model when an object is processed by the property mapper.
Note, that there are some limitations using XCLASS, so it is highly recommended to read the official documentation.