I apologize in advance for this being a bit convoluted. If it were less so, I might not be considering the question. I am working with a platform that allows for extending certain core classes but not others but due to the sequence of events I'm not sure if I can apply the change from the extending class without obliterating the entire parent method (which I want to avoid). Here is a dumbed down version of the chain of classes involved:
Main View Class (extendable):
<?php
class ViewData {
function display($main_data, $sub_id) {
echo $main_data;
$sub_data = new ViewSubData($sub_id);
$sub_data->display();
}
}
Secondary View Class (called from main class above):
<?php
class ViewSubData {
function ViewSubData($id) {
$this->subdata = new SubData($id);
}
function display() {
print_r($this->subdata['data']);
}
}
Data fetcher for secondary view class:
<?php
class SubData {
function SubData($id) {
include("path/to/{$id}.php");
$this = $data_array["$id"];
}
}
Simplified data fetched, as an included array:
<?php
$data_array['xyz']['data']['fred'] = 'flintstone';
$data_array['xyz']['data']['barney'] = 'rubble';
$data_array['xyz']['data']['captain'] = 'caveman';
My extension of the main class (the first above) with pseudo-code of what it would accomplish:
<?php
class MyViewData extends ViewData {
function display($main_data, $sub_id) {
// unset(ViewSubData::subdata['data']['fred']);
parent::display($main_data, $sub_id)
}
}
I have read through the docs on late static binding but it's still really unclear when it works and when it doesn't and, in this case, if it can statically bind multiple-depths from a single point. If this isn't what late static binding is intended for, is there some equivalent way to call the data fetcher statically from the extended MyViewData::display
method so that when the parent calls it non-statically it will already have the modified array and output (or in this case, not output) the modified array member?