JUser, pt3 (getParameters)

17 views
Skip to first unread message

Paladin

unread,
Nov 23, 2009, 2:14:52 PM11/23/09
to Joomla! Framework Development
Been walking through the getParameters method now, and frankly, I'm
lost.

getParameters -- with loadsetupfile true -- goes out and finds an xml
file and loads it. Specifically, it calls the loadSetupFile method of
the parameters object in the user object on that file.

That method parses the xml file, and stores a sequence of
SimpleXMLElement objects in the parameter's "_xml" variable.

Basically, the call chain goes:
theUser->getParameters( true, path/to/xml/file )
theUser->_params->loadSetupFile(path/to/xml/file/user.xml)

and that file calls these in turn:
theSimpleXMLParser->loadFile(path/to/xml/file/user.xml)
theSimpleXMLParser->setXML called on each parameter from the file, and
which assigns the SimpleXMLElement passed to it to the _default
element of the parameter's _xml variable.

what seems to be missing from this is any way to connect these
SimpleXMLElements to actual user parameters.

Aside from the fact I guessed at the correct format for the xml file
because I couldn't find the docs on it, I'm still wondering:

How, precisely, does the information from the parameter file get from
theUser->_params->_xml to anywhere it's going to be used? It doesn't
seem to get from there to anywhere the user object is able to reach,
with either getParam or setParam or setParameters.

Ian MacLennan

unread,
Nov 23, 2009, 10:20:39 PM11/23/09
to joomla-dev...@googlegroups.com
The XML file is used to render the parameter form.  The values aren't stored in the actual XML file.

Ian

Paladin

unread,
Nov 24, 2009, 12:26:22 AM11/24/09
to Joomla! Framework Development


On Nov 23, 9:20 pm, Ian MacLennan <ian.maclen...@joomla.org> wrote:
> The XML file is used to render the parameter form.  The values aren't stored
> in the actual XML file.

Does this mean there's a difference between Params and Parameters?
That get/set/defParam work with completely different data than get/
setParameters?

Ian MacLennan

unread,
Nov 24, 2009, 9:24:45 AM11/24/09
to joomla-dev...@googlegroups.com
Hmmm...  I may have misspoke, because the old values of course get rendered in the form.

Here's what happens:
$param = new JParameter($data, $xmlFilePath);
echo $param->render();
        render:
               calls getParams()
                        getParams
                                iterates through the children of the specified group and invokes getParam
                                       getParam
                                              loads the proper element type
                                              calls its own get method (which is inherited from JRegistry) to retrieve its value
                                              invokes the JParameterType render method to return the HTML for the parameter
                                getParams then pieces those all together to render the final form


Then, when the user submits, the parameter data gets sent as a post array.  This is encoded to JSON (used to be loose INI) and is stored in the params field in the DB.  The data in this field is used as input data to the constructor when the new JParameter is created.

Ian

Paladin

unread,
Nov 24, 2009, 10:33:34 AM11/24/09
to Joomla! Framework Development


On Nov 24, 8:24 am, Ian MacLennan <ian.maclen...@joomla.org> wrote:
> Hmmm...  I may have misspoke, because the old values of course get rendered
> in the form.
>
> Here's what happens:
> $param = new JParameter($data, $xmlFilePath);
> echo $param->render();
>         render:
>                calls getParams()
>                         getParams
>                                 iterates through the children of the
> specified group and invokes getParam
>                                        getParam
>                                               loads the proper element type
>                                               calls its own get method
> (which is inherited from JRegistry) to retrieve its value
>                                               invokes the JParameterType
> render method to return the HTML for the parameter
>                                 getParams then pieces those all together to
> render the final form

But the question is about JUser::getParameters, not getParam or
getParams (the latter isn't part of JUser, anyway). I've seen,
understood and already tested getParam; I can't write tests for
getParameters until I understand what it's supposed to be doing, and
so far it seems to me it does nothing at all that anything else uses.
And the question possibly gets more complicated when I note that I
have as yet been completely unable to find a single example of this
call "in the wild" so I could learn from it.

JUser::setParameters stores a new parameter object in the user object,
so that's pretty clear, even if it also is not used anywhere in Joomla
that I've been able to discover. But the function and purpose for the
getParameters method completely escapes me.

I honestly don't understand why either of those methods exist, but I
think I can at least write a reasonable test for setParameters. I
can't begin to test getParameters until I can figure out what it's
supposed to be used for.

Ian MacLennan

unread,
Nov 24, 2009, 10:51:03 AM11/24/09
to joomla-dev...@googlegroups.com
He...  sorry.  My bad.  I'll look at it and see if anything rings a bell when I get a chance.

Ian
Reply all
Reply to author
Forward
0 new messages