setData($data); } $this->setNode($node); } /** * * get the data held in the config container as an array * if a node is not found, return an empty array rather than the whole data array * * @param string $node * * @return array */ public function getData($node = null) { if ($node !== null) { $this->setNode($node); } if ($this->_node !== null) { $iterator = new \RecursiveIteratorIterator( new \RecursiveArrayIterator($this->_data), \RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $key => $array) { if ($key == $this->_node) { return $array; } } return array(); } return (array)$this->_data; } /** * * set the config object data * * @param mixed $data * * @return $this */ public function setData($data) { $this->clearData(); $this->addData($data); return $this; } /** * * clear data * * @return $this */ public function clearData() { $this->_data = array(); return $this; } /** * * get the node name * * @return string */ public function getNode() { return $this->_node; } /** * * set the node for the config array * * @param string $node */ public function setNode($node) { $this->_node = $node; } /** * * add data * * @param array $data * * @return $this */ abstract public function addData($data); }