Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
46d28496
Commit
46d28496
authored
Mar 13, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update fromArray to support forced lists on specific tags
parent
da2c3c1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
Config.php
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
+12
-5
No files found.
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
View file @
46d28496
...
...
@@ -72,11 +72,12 @@ class Config extends Singleton
/**
* serialize xml to array structure (backwards compatibility mode)
* @param null|array $forceList force specific tags to be contained in a list.
* @param DOMNode $node
* @return string|array
* @throws ConfigException
*/
public
function
toArray
(
$node
=
null
)
public
function
toArray
(
$
forceList
=
null
,
$
node
=
null
)
{
$result
=
array
();
$this
->
checkvalid
();
...
...
@@ -87,11 +88,12 @@ class Config extends Singleton
foreach
(
$node
->
children
()
as
$xmlNode
)
{
if
(
$xmlNode
->
count
()
>
0
)
{
$tmpNode
=
$this
->
toArray
(
$xmlNode
);
$tmpNode
=
$this
->
toArray
(
$
forceList
,
$
xmlNode
);
if
(
array_key_exists
(
$xmlNode
->
getName
(),
$result
))
{
$old_content
=
$result
[
$xmlNode
->
getName
()];
// check if array content is associative, if move items to list
if
(
array_keys
(
$old_content
)
!==
range
(
0
,
count
(
$old_content
)
-
1
))
{
if
(
array_keys
(
$old_content
)
!==
range
(
0
,
count
(
$old_content
)
-
1
)
||
array_key_exists
(
$xmlNode
->
getName
(),
$forceList
))
{
$result
[
$xmlNode
->
getName
()]
=
array
();
$result
[
$xmlNode
->
getName
()][]
=
$old_content
;
}
...
...
@@ -111,7 +113,12 @@ class Config extends Singleton
$result
[
$xmlNode
->
getName
()][]
=
$xmlNode
->
__toString
();
}
else
{
// single content item
$result
[
$xmlNode
->
getName
()]
=
$xmlNode
->
__toString
();
if
(
array_key_exists
(
$xmlNode
->
getName
(),
$forceList
))
{
$result
[
$xmlNode
->
getName
()]
=
array
();
$result
[
$xmlNode
->
getName
()][]
=
$xmlNode
->
__toString
();
}
else
{
$result
[
$xmlNode
->
getName
()]
=
$xmlNode
->
__toString
();
}
}
}
}
...
...
@@ -337,7 +344,7 @@ class Config extends Singleton
// try to read backup info from xml
$xmlNode
=
simplexml_load_file
(
$filename
,
"SimpleXMLElement"
,
LIBXML_NOERROR
|
LIBXML_ERR_NONE
);
if
(
isset
(
$xmlNode
->
revision
))
{
$result
[
$filename
]
=
$this
->
toArray
(
$xmlNode
->
revision
);
$result
[
$filename
]
=
$this
->
toArray
(
null
,
$xmlNode
->
revision
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment