$myObject = new MyClass(); GeneralUtility::addInstance(MyClass::class, $myObject);
$myObject = GeneralUtility::makeInstance(MyClass::class);This code retrieves an instance of the MyClass class from the registry. If an instance has not been added to the registry with addInstance, this function will create a new instance. These examples demonstrate how GeneralUtility::addInstance can be used to create a global registry of singleton objects for use within TYPO3 CMS. This function is part of the TYPO3 CMS Core package library.