OpenMediaVault  3.0 (Erasmus)
The open network attached storage solution
Public Member Functions | List of all members
OMV\Config\DatabaseBackend Class Reference

Public Member Functions

 __construct ($filename, $forceReload=TRUE, $autoCommit=TRUE, $versioning=FALSE)
 
 addEnum ($enum)
 
 setVersioning ($enable)
 
 load ()
 
 save ()
 
 get ($xpath)
 
 getList ($xpath)
 
 getXPathList ($xpath)
 
 set ($xpath, $data)
 
 replace ($xpath, $data)
 
 update ($xpath, $data)
 
 delete ($xpath)
 
 exists ($xpath)
 
 count ($xpath)
 
 compare ($xpath, $data)
 
 revert ($filename)
 
 unlinkRevisions ()
 

Detailed Description

See http://www.zvon.org/xxl/XPathTutorial/General/examples.html for some helpful XPath examples.

Constructor & Destructor Documentation

OMV\Config\DatabaseBackend::__construct (   $filename,
  $forceReload = TRUE,
  $autoCommit = TRUE,
  $versioning = FALSE 
)

Constructor

Parameters
filenameThe path to the XML document.
forceReloadSet to TRUE to reload the XML document everytime before any action is performed on the XML document. Defaults to TRUE.
autoCommitSet to TRUE to automatically commit the XML document modifications after write-access. Defaults to TRUE.
versioningSet to TRUE to automatically create a revision file for all changes. Files will look like <filename>.<revision>, e.g. <filename>.0015. Defaults to FALSE.

Member Function Documentation

OMV\Config\DatabaseBackend::addEnum (   $enum)

Add an enum.

OMV\Config\DatabaseBackend::compare (   $xpath,
  $data 
)

Compare the configuration from the given XPath expression with the given data.

Parameters
xpathThe XPath expression to execute.
dataThe data to compare.
Returns
Returns 0 if the data is equal, otherwise -1. On error boolean FALSE is returned.
OMV\Config\DatabaseBackend::count (   $xpath)

Get the number of nodes matching the given XPath expression.

Parameters
xpathThe XPath expression to execute.
Returns
Get the number of nodes matching the given XPath expression or FALSE on failure (e.g. XPath expression is malformed).
OMV\Config\DatabaseBackend::delete (   $xpath)

Delete the nodes matching the given XPath expression. This function is protected by mutual exclusion, thus the function will be blocked until it can acces the protected section.

Parameters
xpathThe XPath expression to execute.
Returns
Returns the deleted nodes, otherwise FALSE.
OMV\Config\DatabaseBackend::exists (   $xpath)

Check if the data at the given XPath expression exists.

Parameters
xpathThe XPath expression to execute.
Returns
TRUE if data exists, otherwise FALSE. If the XPath expression is malformed FALSE will be returned, too.
OMV\Config\DatabaseBackend::get (   $xpath)

Get the configuration for the given XPath expression.

Parameters
xpathThe XPath expression to execute.
Returns
The requested value or an array containing the requested value if the XPath expression matches multiple configuration objects. If the XPath expression does not match NULL will be returned.
OMV\Config\DatabaseBackend::getList (   $xpath)

Get the configuration for the given XPath expression as a list.

Parameters
xpathThe XPath expression to execute.
Returns
An array containing the requested configuration objects, otherwise an empty array.
OMV\Config\DatabaseBackend::getXPathList (   $xpath)

Get the XPath location path of the objects addressed by the given XPath as a list.

Parameters
xpathThe XPath expression to execute.
Returns
An array containing the XPath to the objects, otherwise an empty array.
OMV\Config\DatabaseBackend::load ( )

Load the configuration file.

Returns
TRUE if successful, otherwise FALSE.
OMV\Config\DatabaseBackend::replace (   $xpath,
  $data 
)

Replace the data at the given XPath expression. If the given XPath expression does not exist, then the method will exit immediatelly. This function is protected by mutual exclusion, thus the function will be blocked until it can acces the protected section.

Parameters
xpathThe XPath expression to execute.
dataThe data to set for the given XPath expression.
Returns
TRUE if successful, otherwise FALSE.
OMV\Config\DatabaseBackend::revert (   $filename)

Revert changes. All existing revision files will be deleted.

Parameters
filenameThe revision file. Defaults to NONE.
Note
This only takes action if versioning is enabled.
Returns
None.
OMV\Config\DatabaseBackend::save ( )

Save configuration file. This function is protected by mutual exclusion, thus the function will be blocked until it can acces the protected section.

Returns
TRUE on success, otherwise FALSE.
OMV\Config\DatabaseBackend::set (   $xpath,
  $data 
)

Set the data at the given XPath expression. This function is protected by mutual exclusion, thus the function will be blocked until it can acces the protected section.

Parameters
xpathThe XPath expression to execute.
dataThe data to set for the given XPath expression.
Returns
TRUE if successful, otherwise FALSE.
OMV\Config\DatabaseBackend::setVersioning (   $enable)

Create a revision for all changes.

Parameters
enableSet to TRUE to automatically create a revision file for all changes. Files will be created like <filename>.<revision>, e.g. <filename>.0015. Set to FALSE to disable versioning on changes.
OMV\Config\DatabaseBackend::unlinkRevisions ( )

Unlink all revision files. Note, this only takes action if versioning is enabled.

Returns
TRUE if successful, otherwise FALSE.
OMV\Config\DatabaseBackend::update (   $xpath,
  $data 
)

Update the existing configuration for the given XPath expression. The given data will override the existing configuration. If the given XPath expression does not exist, then the method will exit immediatelly. This function is protected by mutual exclusion, thus the function will be blocked until it can acces the protected section.

Parameters
xpathThe XPath expression to execute.
dataThe data to set for the given XPath expression.
Returns
TRUE if successful, otherwise FALSE.

The documentation for this class was generated from the following file: