I have an observer class that contains variables that for the most part are used internally; however, I would like to access one of the variables after the notifier event has triggered the observer, but I don't see how the internal data/functions can be accessed if a separate variable hasn't been uniquely declared to be that class type. (Somewhat trying to figure out what variable can be accessed to access the data of the observer.)
So for example if I have the following observer that is called by an appropriate config file:
What I would like to do is elsewhere in the "main" body I would like to retrieve the condition of $_val as it relates to the above class/function. I've found that I could "create" a variable by establishing a variable as global and then setting that global variable equal to the internal variable... This directly "transfers" it to the global side of data; however, I'm trying to see if there is an alternative method of accessing the internal data through some other method. Seems that even if an accessor function were developed there would still need to be something to reference to activate the function... I do (now) recognize that the data was declared private, so I plan to test with that set as public to see if I can find a way to access it while awaiting a kind individual that may have figured this out to post...Code:class observer_class_to_test extends base { private $_val = false; function __construct() { global $zco_notifier; $attachNotifier = array(); $attachNotifier[] = 'NOTIFY_ME_WHEN_THIS_NOTIFIER_ACTIVATES'; $zco_notifier->attach($this, $attachNotifier); } function updateNotifyMeWhenThisNotifierActivates(&$callingClass, $notifier, $paramsArray){ global $some_value; if ([condition_is_true]) { $this->_val = true; } } }
I've generically provided information associated with the conditions as an example of structure rather than specific function...


Reply With Quote
