access full object data set from within another class into the main class
<p>I have searched hi and low for a solution to this without any luck whatsoever, so i posting as a last resort in hope someone can help me.</p>

<pre><code>
class Main
{
    private $data = array();

    private $a;
    private $b;

    function __contruct()
    {
    }

    public function a()
    {
        if (!is_object($this->a))
        {
            $this->a = new A();
        }

        return $this->a;

    }

    public function b()
    {
        if (!is_object($this->b))
        {
            $this->b = new B();
        }

        return $this->b;

    }

    protected function set_data($value)
    {
        $this->data = $value;
    }
}

class A extends Main
{
    function __contrust()
    {
        parent::_construct();
    }

    public function test($value)
    {
        $this->set_data($value);

        return $this;
    }
}

class B extends Main
{
    function __contrust()
    {
        parent::_construct();
    }

    public function test($value)
    {
        $this->set_data($value);

        return $this;
    }

    public function get_data()
    {
        print_r($this->a);
    }
}

$m = new Main();
$m->a()->test('add A class data');
$m->b()->test('add B class data');
$m->b()->get_data(); // want to use class A object data here
</code></pre>

<p><em><strong>edit</em></strong></p>

<pre><code>
[a:private] => A Object
        (
            [data:private] => Array
                (
                    [0] => Array
                        (
                            [name] => foo
                            [data] => 65
                        )
                    [1] => Array
                        (
                            [name] => bar
                            [data] => 65
                        )
                )

            [a:private] => 
            [b:private] => 
        )
</code></pre>

<p>I have a method in the main class that finds the name key im looking for and returns its index so i can manipulate its data which works fine from its calling class. However class B needs to be able to set its own data back to the data array as well as get a hold of class A object data so i can manipulate its data.</p>

<p>So as you can see after i instantiate the main class and fire A class i want to be able to use the object data of A in my B class...</p>

<p>Would greatly appreciate any help possible.</p>

<p>Thanks,</p>

<p>Darren</p>
