In my plugin xml file I have a large number of parameters to retrieve, about 100. Presently, to set a more friendly name to parameters, I am retrieving them like this:

public function __construct(& $subject, $config)
    parent::__construct($subject, $config);

    // Load login parameters
    $this->simple_name001 = $this->params->get('complex_name001', 'default_value');
    $this->simple_name... = $this->params->get('complex_name...', 'default_value');
    $this->simple_name100 = $this->params->get('complex_name100', 'default_value');

What's the proper way to handle with this? Should I handle this in a external file (and then use like an array)?

  • You don't have to define them all in your constructor. You could simply call them in your plugin events when you require them. For example calling a login redirect URL parameter in the onUserLogin event and a logout redirect URL parameter in the onUserLogout event
    – Lodder
    Mar 26, 2015 at 12:43
  • @Lodder That makes sense. But as they are many and as I want to give them a more simple and friendly name could I handle them in another way? Perhaps using an array of params?
    – n.h.
    Mar 26, 2015 at 12:53
  • What's giving them the complex name? Could you just give them a simpler name to begin with? Apr 1, 2015 at 4:35

1 Answer 1


$this->params is the Registry class which implements ArrayAccess so the properties of the registry can be accessed as an array. This allows you to do something like this:

$i = 1;

foreach ($this->params as $parameter)
    $property = 'simple_name' . $i;
    $this->{$property} = $parameter;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.