25 #require_once 'Zend/Config.php'; 28 #require_once 'Zend/Xml/Security.php'; 31 #require_once 'Zend/Xml/Exception.php'; 46 const XML_NAMESPACE =
'http://framework.zend.com/xml/zend-config-xml/1.0/';
87 #require_once 'Zend/Config/Exception.php'; 91 $allowModifications =
false;
95 if (isset(
$options[
'allowModifications'])) {
96 $allowModifications = (bool)
$options[
'allowModifications'];
98 if (isset(
$options[
'skipExtends'])) {
99 $this->_skipExtends = (bool)
$options[
'skipExtends'];
103 set_error_handler(array($this,
'_loadFileErrorHandler'));
104 if (strstr($xml,
'<?xml')) {
109 #require_once 'Zend/Config/Exception.php'; 111 "Error failed to load $xml file" 115 #require_once 'Zend/Config/Exception.php'; 122 restore_error_handler();
124 if ($this->_loadFileErrorStr !==
null) {
125 #require_once 'Zend/Config/Exception.php'; 129 if ($section ===
null) {
130 $dataArray = array();
131 foreach (
$config as $sectionName => $sectionData) {
135 parent::__construct($dataArray, $allowModifications);
136 }
else if (is_array($section)) {
137 $dataArray = array();
138 foreach ($section as $sectionName) {
139 if (!isset(
$config->$sectionName)) {
140 #require_once 'Zend/Config/Exception.php'; 147 parent::__construct($dataArray, $allowModifications);
149 if (!isset(
$config->$section)) {
150 #require_once 'Zend/Config/Exception.php'; 155 if (!is_array($dataArray)) {
157 $dataArray = array($section => $dataArray);
160 parent::__construct($dataArray, $allowModifications);
163 $this->_loadedSection = $section;
179 #require_once 'Zend/Config/Exception.php'; 184 $nsAttributes = $thisSection->attributes(self::XML_NAMESPACE);
186 if (isset($thisSection[
'extends']) || isset($nsAttributes[
'extends'])) {
187 $extendedSection = (string) (isset($nsAttributes[
'extends']) ? $nsAttributes[
'extends'] : $thisSection[
'extends']);
190 if (!$this->_skipExtends) {
207 protected function _toArray(SimpleXMLElement $xmlObject)
210 $nsAttributes = $xmlObject->attributes(self::XML_NAMESPACE);
213 if (
count($xmlObject->attributes()) > 0) {
214 foreach ($xmlObject->attributes() as $key =>
$value) {
215 if ($key ===
'extends') {
221 if (array_key_exists($key,
$config)) {
222 if (!is_array(
$config[$key])) {
234 if (
count($xmlObject->children(self::XML_NAMESPACE)) > 0) {
235 if (
count($xmlObject->children()) > 0) {
236 #require_once 'Zend/Config/Exception.php'; 240 $dom = dom_import_simplexml($xmlObject);
241 $namespaceChildNodes = array();
245 foreach ($dom->childNodes as $node) {
246 if ($node instanceof DOMElement && $node->namespaceURI === self::XML_NAMESPACE) {
247 $namespaceChildNodes[] = $node;
251 foreach ($namespaceChildNodes as $node) {
252 switch ($node->localName) {
254 if (!$node->hasAttributeNS(self::XML_NAMESPACE,
'name')) {
255 #require_once 'Zend/Config/Exception.php'; 259 $constantName = $node->getAttributeNS(self::XML_NAMESPACE,
'name');
261 if (!defined($constantName)) {
262 #require_once 'Zend/Config/Exception.php'; 266 $constantValue = constant($constantName);
268 $dom->replaceChild($dom->ownerDocument->createTextNode($constantValue), $node);
272 #require_once 'Zend/Config/Exception.php'; 277 return (
string) simplexml_import_dom($dom);
281 if (
count($xmlObject->children()) > 0) {
282 foreach ($xmlObject->children() as $key =>
$value) {
296 if (array_key_exists($key,
$config)) {
297 if (!is_array(
$config[$key]) || !array_key_exists(0,
$config[$key])) {
306 }
else if (!isset($xmlObject[
'extends']) && !isset($nsAttributes[
'extends']) && (
count(
$config) === 0)) {
elseif(isset( $params[ 'redirect_parent']))
static scanFile($file, DOMDocument $dom=null)
static scan($xml, DOMDocument $dom=null)
__construct($xml, $section=null, $options=false)
_processExtends(SimpleXMLElement $element, $section, array $config=array())
_assertValidExtend($extendingSection, $extendedSection)
_toArray(SimpleXMLElement $xmlObject)
_arrayMergeRecursive($firstArray, $secondArray)