Exemple #1
0
 public function __construct($data = array())
 {
     //if there is more arguments or data is not an array
     if (func_num_args() > 1 || !is_array($data)) {
         //just get the args
         $data = func_get_args();
     }
     foreach ($data as $key => $value) {
         if (!is_array($value)) {
             continue;
         }
         $class = get_class($this);
         $data[$key] = $this->{$class}($value);
     }
     parent::__construct($data);
 }
Exemple #2
0
if(!class_exists('Eden_Registry')){class Eden_Registry extends Eden_Type_Array{public static function i(){return self::_getMultiple(__CLASS__);}public function __construct($data=array()){if(func_num_args() > 1 || !is_array($data)){$data=func_get_args();}foreach($data as $key=>$value){if(!is_array($value)){continue;}$class=get_class($this);$data[$key]=$this->$class($value);}parent::__construct($data);}public function __toString(){return json_encode($this->getArray());}public function get($modified=true){$args=func_get_args();if(count($args)==0){return $this;}$key=array_shift($args);if($key===false){if(count($args)==0){return $this->getArray();}$modified=$key;$key=array_shift($args);array_unshift($args,$modified);}if(!isset($this->_data[$key])){return NULL;}if(count($args)==0){return $this->_data[$key];}if($this->_data[$key] instanceof Eden_Registry){return call_user_func_array(array($this->_data[$key],__FUNCTION__),$args);}return NULL;}public function getArray($modified=true){$array=array();foreach($this->_data as $key=>$data){if($data instanceof Eden_Registry){$array[$key]=$data->getArray($modified);continue;}$array[$key]=$data;}return $array;}public function isKey(){$args=func_get_args();if(count($args)==0){return $this;}$key=array_shift($args);if(!isset($this->_data[$key])){return false;}if(count($args)==0){return true;}if($this->_data[$key] instanceof Eden_Registry){return call_user_func_array(array($this->_data[$key],__FUNCTION__),$args);}return false;}public function offsetGet($offset){if(!isset($this->_data[$offset])){return NULL;}if($this->_data[$offset] instanceof Eden_Registry){return $this->_data[$offset]->getArray();}return $this->_data[$offset];}public function remove(){$args=func_get_args();if(count($args)==0){return $this;}$key=array_shift($args);if(!isset($this->_data[$key])){return $this;}if(count($args)==0){unset($this->_data[$key]);return $this;}if($this->_data[$key] instanceof Eden_Registry){return call_user_func_array(array($this->_data[$key],__FUNCTION__),$args);}return $this;}public function set($value){$args=func_get_args();if(count($args) < 2){return $this;}$key=array_shift($args);if(count($args)==1){if(is_array($args[0])){$args[0]=self::i($args[0]);}$this->_data[$key]=$args[0];return $this;}if(!isset($this->_data[$key]) || !($this->_data[$key] instanceof Eden_Registry)){$this->_data[$key]=self::i();}call_user_func_array(array($this->_data[$key],__FUNCTION__),$args);return $this;}}}
Exemple #3
0
 public function __construct($data = array())
 {
     if (func_num_args() > 1 || !is_array($data)) {
         $data = func_get_args();
     }
     foreach ($data as $key => $value) {
         if (!is_array($value)) {
             continue;
         }
         $class = get_class($this);
         $data[$key] = $this->{$class}($value);
     }
     parent::__construct($data);
 }