[TYPO3-mvc] Cannot get findByProperty to work

Mark Kuiphuis spam at markyourweb.com
Mon Jan 2 11:02:40 CET 2012


Hi Henjo,

Thanks for your reply...

Indeed I now found out the difference between findByProperty and findOneByProperty....

I didn't find an example like I experienced in the book "Zukunftsichere Extensions 
mit Extbase und Fluid", but if I'm not mistaken that book is based on Extbase 1.2 and 
Franz mentioned that from version 1.3 no longer an array has been returned but a 
queryResultObject....

Cheers, Mark

On 2/01/12 7:40 PM, Henjo Hoeksma wrote:
> Hi Mark,
>
> when you use the magic of the findByProperty methods, keep in mind the
> return will be an object storage (unless you return them specifically as an
> array - like you did with Franz' snippet).
> If you expect 1 object based on an id (like uid), you can use
> findOneByMyId($myId) which will give you the single object and not the
> object storage as a result.
>
> Kind regards,
>
> Henjo
>
> Problems are small because we learned how to deal with them.
> Problems are big because we need to learn how to deal with them.
>
>
> On Mon, Jan 2, 2012 at 10:09, Mark Kuiphuis<spam at markyourweb.com>  wrote:
>
>> Damn...that took me a while to figure this one out.....
>> Really starting to enjoy the non descriptive error messages (if any error
>> message at all) (*NOT*)
>>
>> Turned out that I had to do this:
>>
>> $orders = $this->orderRepository->**findByTransactionId($**
>> transactionId)->toArray();
>>
>> instead of only:
>>
>> $orders = $this->orderRepository->**findByTransactionId($**transactionId);
>>
>> I found this snippet from Franz Koch after searching the net for quite
>> some hours today...
>>
>>> the reason for this is, that as of Extbase 1.3 the repository doesn't
>>> any longer return a array but a queryResultObject, and thus the
>>> array_merge fails. In order to get it working try adding ->toArray()
>>> after "findByStates(...)" (findByStates($allowedStates)-**>toArray()).
>>
>>> --
>>> kind regards,
>>> Franz Koch
>>
>> Thanks Franz :-)
>>
>> Regards, Mark
>>
>>
>> On 2/01/12 5:17 PM, Mark Kuiphuis wrote:
>>
>>> Hi Georg,
>>>
>>> I hadn't, but just added this one, but no change...(orders are saved in
>>> PID 0
>>> anyway)..could that maybe generating the error?
>>>
>>> I also tried to override this function in the OrderRepository with the
>>> following
>>> function:
>>>
>>> public function findByTransactionId($**transactionId){
>>> $query = $this->createQuery();
>>> $query->getQuerySettings()->**setRespectStoragePage(FALSE);
>>>
>>> return $query->matching($query->**equals('transaction_id',
>>> $transactionId))->execute();
>>> }
>>>
>>> I do use the setRespectStoragePage(FALSE) there...(however, orders are
>>> saved in PID
>>> 0...something else I need to solve :(
>>>
>>> The generated SQL looks like this:
>>>
>>> SELECT tx_travelprograms_domain_**model_order.* FROM
>>> tx_travelprograms_domain_**model_order WHERE
>>> tx_travelprograms_domain_**model_order.transaction_id = ? AND
>>> tx_travelprograms_domain_**model_order.deleted=0 AND
>>> tx_travelprograms_domain_**model_order.hidden=0 AND
>>> tx_travelprograms_domain_**model_order.pid IN (0)
>>>
>>> Without debugging with Tx_ExtDebug::var_dump($orders) I do get to see the
>>> view, but
>>> no variables {order.uid} etc. etc. will be replaced...(but are added to
>>> the view with
>>> $this->view->assign('order', $order);
>>>
>>> With debugging with Tx_ExtDebug::var_dump($orders) I do get the error:
>>>
>>> #1210859206: Cannot return value of private property "warning.
>>>
>>> Tx_Extbase_Reflection_**Exception thrown in file
>>> /private/var/www/typo3_src/**typo3_src-4.5.10/typo3/sysext/**
>>> extbase/Classes/Reflection/**PropertyReflection.php
>>> in line 95.
>>>
>>> Potentially this could be an Ext_Debug bug... but looking in the
>>> PropertyReflection.php class it looks like $this->isPrivate() returns
>>> TRUE....but the
>>> property $transactionId in the model has been set to protected..(I also
>>> tried public,
>>> but again to no avail)....
>>>
>>> Thanks, Mark
>>>
>>> On 2/01/12 4:50 PM, Georg Ringer wrote:
>>>
>>>> Hi Mark,
>>>>
>>>> did you set the pid in your TS?
>>>> this would be plugin.tx_extkey.persistence.**storagePid
>>>>
>>>> byUid ignores this setting but all of the others do you use this.
>>>>
>>>> georg
>>>>
>>>
>>>
>> ______________________________**_________________
>> TYPO3-project-typo3v4mvc mailing list
>> TYPO3-project-typo3v4mvc@**lists.typo3.org<TYPO3-project-typo3v4mvc at lists.typo3.org>
>> http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**
>> project-typo3v4mvc<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc>
>>



More information about the TYPO3-project-typo3v4mvc mailing list