[TYPO3-mvc] Problem getting an instance of an object in controller

Henjo Hoeksma me at henjohoeksma.nl
Wed Apr 6 16:44:34 CEST 2011


On 2011-04-06 15:25:31 +0200, Franz Koch said:

> Hey,
> 
>> I need to compare a XML posted object to an object in the database.
>> 
>> What I do is something like:
>> 
>> $rep = t3lib_div::makeInstance('Object_Repos');
>> $objectInDb = $rep->findByProperty('PropertyValue');
> ...
>> Is this due to the new inject dependency ?
> 
> if your using Extbase 1.3+ then yes. You have to create the instance of 
> the repository using the objectManager.
> 
> $rep = $this->objectManager->get('Tx_Ext_Domain_Repository_ObjectRepository');
> ...

Hi Franz,

thanks for your response.

yes, 1.3+. I allready tried this, and now with your suggested code I 
get the same error.

<code minified...>
case 'delete':
		    $rep = 
$this->objectManager->get('Tx_Ext_Domain_Repository_ObjectRepository');
		    $object = $rep->findByProperty((int)$xml->value);
		    if(count($object) == '1'){
			$rep->remove($object);
			$response = '1';
		    } else {
			$response = 'Delete action given, but the specified object was not found';
		    }
		    break;
</code>


Could it be because this object has a related object as well that 
should be deleted? Should that object be instantiated as well (thought 
not so...)

Thanks,

Henjo



More information about the TYPO3-project-typo3v4mvc mailing list