Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.5.7

Request #6635 Add a 'concatenation' method to HTML_AJAX_Action
Submitted: 2006-01-30 20:00 UTC Modified: 2006-08-15 12:29 UTC
From: atex Assigned:
Status: Closed Package: HTML_AJAX (version 0.3.3)
PHP Version: 5.1.1 OS: Linux
Roadmaps: (Not assigned)    
Subscription  


 [2006-01-30 20:00 UTC] atex
Description: ------------ Basically, I have a situation where I can call one method from a second method. The problem is I return an HTML_AJAX_Action object from the first method and need to return that, but I also need to return the HTML_AJAX_Action object that I had already been creating as I was going through the second method. The problem is, I can't call the first method from the second method without first doing a few other assignAttr() calls, so it's not as simple as calling method1 first and then calling assignAttr() on the object that the first method created. In short, a concatenation method in HTML_AJAX_Action would be very helpful. Test script: --------------- method1() { $r = HTML_AJAX_Action(); $r->assignAttr('id', 'innerHTML', 'text'); return $r; } method2() { $r = HTML_AJAX_Action(); $r->assignAttr('id2', 'innerHTML', 'text2'); ... $r2 = $this->method1(); $r->concat($r2); return $r; } Expected result: ---------------- This would return an HTML_AJAX_Action object that contains the data from both the call from method1() inside method2() as well as the data that is being collected during method2(). Actual result: -------------- Currently, the concat method does not exist in HTML_AJAX_Action, so this would not function.

Comments

 [2006-01-31 00:29 UTC] jeichorn at php dot net
I don't think concat is a very good name for this method, maybe combine. The basic docs for the combine function would be: HAA::combine($haaInstance) Take all actions in the HAA instance passed in and append them to the end of the current HAA instance. If this approach suits your needs let me know, i'll see if i can get it implemented.
 [2006-01-31 12:25 UTC] atex
I agree that "combine" is probably a better name for the method. Your description of the combine function also seems to sync with what I was thinking about. I thought something as simple as the following would work, but since I'm not sure how everything else meshes together, it may be too vague (i.e. dealing with $contentType and $payload): function combine($act_obj) { if (is_a($act_obj, 'HTML_AJAX_Action')) { foreach ($act_obj->_actions as $action) { $this->_actions[] = $action; } return true; } else { return false; } }
 [2006-08-14 18:14 UTC] auroraeosrose (emsmith)
A method to do this has been added in svn $r1 = HTML_AJAX_Action(); $r->assignAttr('id', 'innerHTML', 'text'); $r2 = HTML_AJAX_Action(); $r2->assignAttr('id', 'innerHTML', 'text'); $r1->combineActions($r2); Someone want to close this?