I'm trying to get my design straight and am wondering if there is a way to "attach" a child-class to an already instantiated parent-class.
Example:
CLASS webshopOrder { ... }
CLASS deliveryAddress EXTENDS webshopOrder {
public function __construct($parentOrder) {
// pseudo: parent = $parentOrder;
}
}
$order = new webshopOrder;
$deliveryAddress = new deliveryAddress($order);
Now, when I need the delivery address later in my code I don't want the order to initiate (expensively) again and would like to use the existing instance. Any hint would be appreciated.