[TYPO3-english] How to instance the model by code in Typo3 6.2.15
Christian Platt
christian.platt at pharmaline.de
Mon Nov 9 06:35:03 CET 2015
Hi folks,
i am trying to import data from xml source into my database.
So i created a model to import the data. So i need an instance of my data model
Ín 4.7 extbase i used something like:
$newEntry = t3lib_div::makeInstance('Tx_Phlgallery_Domain_Model_Gallery');
to get en instance from the data model. In 6.2. this does not work anymore. I searched and found, that...
$newHockeyArea=\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Pharmaline\\hockey\\Classes\\Domain\\Model\\HockeyArea');
should do the job, but i get
Fatal error: Class 'Pharmaline\hockey\Classes\Domain\Model\HockeyArea' not found in /Library/WebServer/Documents/typo62shop/typo3_src-6.2.15/typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 4434
i searched further and found that the object manager should do the job
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$newHockeyArea = $objectManager->get('Pharmaline\\hockey\\Classes\\Domain\\Model\\HockeyArea');
With that code it also does not work, i get
1289386765: Could not analyse class:Pharmaline\hockey\Classes\Domain\Model\HockeyArea maybe not loaded or no autoloader? (More information <http://typo3.org/go/exception/CMS/debug/1289386765>)
so, it looks for me that the Model in not found??
What is wrong? Normaly i would get the properties of my Domain Modell, fill it an add it to my repository….
Christian Platt
More information about the TYPO3-english
mailing list