The recommended way to get a strict Parameter doesn't really work. You can't just say:

Parameter::get('mykey','strict');

This fails because all the other following arguments need to be call-by-reference.
So if you want the strict call you have the rather complicated:

$context='strict';
echo Parameter::get('mykey',$context);

Additionally you also need the "->getProcessedData()->getValue();" part everytime.
This is a bit complicated for simple strings or secrets. I'd suggest providing a convenience method:

echo Parameter::getStrictValue('mykey');

that does all these things at once and is thus equivalent to:

$context='strict';
echo Parameter::get('mykey',$context)->getProcessedData()->getValue();

Comments

rgpublic created an issue. See original summary.

  • mxh committed f3638e46 on 1.0.x
    Issue #3537342: Perhaps consider providing a simpler alternative get...
mxh’s picture

Status: Active » Fixed

I have added a convenience shortcut into the Parameter class. It should now be possible to do the following:

$value = Parameter::value('myparam', 'strict');

Also this should work now as originally intended:

$parameter = Parameter::get('myparam', 'strict');
mxh’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.