How do I use $this->var1
inside a method that is called from a static method?
I have this method:
static public function getModuleConfigInputfields(array $data) {
$fields = new InputfieldWrapper();
$modules = Wire::getFuel('modules');
$field = $modules->get("InputfieldText");
$field->attr('name+id', 'apiKey');
$field->attr('value', $data['apiKey']);
$field->label = "API Key (Developer Key)";
$field->description = 'Enter the API key';
$fields->append($field);
$field = $modules->get("InputfieldSelect");
$field->attr('name+id', 'list_id');
$mailing_lists = self::get_mc_lists();
foreach($mailing_lists['data'] as $list)
{
$field->addOption($list->list_name, $list->list_id);
}
$field->label = "Mailing list";
$field->description = 'Choose a mailing list';
$fields->append($field);
return $fields;
}
And I want to call this method:
public function get_mc_lists()
{
$api = new MCAPI($this->apiKey);
$retval = $api->lists();
if ($api->errorCode){
return array('errorcode' => $api->errorCode, 'errormessage' => $api->errorMessage);
} else {
return array('data' => $retval['data'], 'total' => $retval['total']);
}
}
But I am getting this error:
Error Using $this when not in object context (line 31
Line 31, which is: $api = new MCAPI($this->apiKey);
So how can I fix this, work around this... I am really stuck on this
Thanks in advance!