Since I noticed that this is a template that I constantly reprogrammed, I created a DataContainer class that overrides __set , __get , __isset , __unset and implements ArrayAccess , Countable , IteratorAggregate and Serializable
For example, my View class, which displays PHP templates in MVC style, inherits from a DataContainer so that it overloads access to the data that is passed to the template.
Now I find that I want to create a Session class to abstract from working with a low-level PHP session. It seemed to me that this session class will do almost everything that the DataContainer does, but in fact - the DataContainer - it contains the data.
However, if I inherit the DataContainer, then all overloaded calls go into its private $_data . Of course, I can override the methods of the DataContainer public get($key) , public set($key,$val) , etc., but the only thing I would like to do is rename $this->_data to $_SESSION .
Is it possible to set a variable as a reference to a special global such as $_SESSION ?
class Session extends DataContainer {
Is that even a good idea? If not, what do you suggest?
source share