OOP Plugin Development. Including external object

I am developing a plugin by using classes and object oriented programming.

Within my plugin I have included another object as I need to use the functionality of this other object.

I am instantiating the included object within my plugin’s constructor.

require_once (‘path/to/my/IncludedObject’);

class MyPlugin
{
private $IncludedObject;

public function __construct()
{
$this->IncludedObject = new IncludedObject();
}
}

class IncludedObject
{
public $instanceVar = ‘defaultValue’;

public function getInstanceVar()
{
return $this->instanceVar();
}

public function setInstanceVar($instanceVar)
{
$this->instanceVar = $instanceVar;
}
}

The $instaceVar is updated after an ajax action within my HTML form commanded by my plugin. So, from the handler within my plugin I call setInstanceVar($_REQUEST[‘newValue’]);

The problem I am facing is that $instanceVar never gets updated and always have the ‘defaultValue’.

Can anyone shed some light on this issue?

Thanks

Read more here:: OOP Plugin Development. Including external object

Leave a Reply

Your email address will not be published. Required fields are marked *