[TYPO3-mvc] The given subject was not a collection..

Thomas Hucke thucke at web.de
Wed Mar 26 20:42:09 CET 2014


Hi Philipp,

I also had this error trying my ext in the new version.
I figured out the the issue in my case was an obviously wrong annotation in 
my model.

The request is being validated - just before it gets passed to your 
controller action.
I got some 1:1 relations in my model and for thos relations I made 
annotations like
    @var 
\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\<myVendor>\<myExtkey>\Domain\Model\<myModel>

Unfortunately during pre-procession the createAction TYPO3 builds a 
collection of validators that should be called to check the request.
When <myModel> is being checked there´s a component TypeHandlingUtility that 
tells T3 "Hey - this parameter <myModel> must be a collection because it´s 
of the type Objectstorage." Hence the following CollectionValidator expects 
a collection type var.
TypeHandlingUtility defines the following colltionstypes:
static protected $collectionTypes = array('array', 'ArrayObject', 
'SplObjectStorage', 'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage', 
'Tx_Extbase_Persistence_ObjectStorage');

If you got a 1:1 relation change your annotation to
   @var \<myVendor>\<myExtkey>\Domain\Model\<myModel>


Then clear all caches and - just to make sure really ALL cached info is 
removed - also both directories in typo3temp/Cache.
Then open a phpadmin session and truncate all tables starting with cf_*. I 
gained the experience that some source code is being cached by the framework 
so it made no difference only changing the source code.

Good luck
Thomas



"Philipp Wrann"  schrieb im Newsbeitrag 
news:mailman.1.1395851873.24651.typo3-project-typo3v4mvc at lists.typo3.org...

I try to validate a new object manually, in the action i get an array passed 
and build a valdationObject like this:
$validatorResolver = 
$this->objectManager->get('TYPO3\\CMS\\Extbase\\Validation\\ValidatorResolver');
/* @var $validatorResolver \TYPO3\CMS\Extbase\Validation\ValidatorResolver 
*/
$modelName = $this->requestService->getModelName($request->getKey());
$validator = $validatorResolver->getBaseValidatorConjunction($modelName);

I need this because i want to use different request objects with different 
validations

now the problem is, that an array like

request : {key:1,identifier:1,package:12}

is validated recursively, but i am passing a allready created entity...

now of course i get validation errors for those properties.

How do i solve this? 



More information about the TYPO3-project-typo3v4mvc mailing list