openmediavault  4.0 (Arrakis)
The open network attached storage solution
Public Member Functions | Protected Member Functions | List of all members
OMV\Config\ConfigObject Class Reference

Public Member Functions

 __construct ($id)
 
 __clone ()
 
 getModel ()
 
 get ($name)
 
 getAssoc ()
 
 getIndexed ()
 
 getDefaultsIndexed ()
 
 getDefaultsAssoc ()
 
 setDefaults ()
 
 set ($name, $value, $validate=TRUE)
 
 setAssoc (array $data, $validate=TRUE, $ignore=FALSE)
 
 setFlatAssoc (array $data, $validate=TRUE, $ignore=FALSE)
 
 setIndexed (array $data, $validate=TRUE, $ignore=FALSE)
 
 remove ($name)
 
 add ($name, $type, $default=NULL)
 
 copy ($name, $targetName)
 
 move ($name, $targetName)
 
 reset ($name)
 
 isEmpty ($name)
 
 isEqual ($name, $value)
 
 isNew ()
 
 setNew ()
 
 createIdentifier ()
 
 getIdentifier ()
 
 isIdentifiable ()
 
 isIterable ()
 
 isReferenceable ()
 
 getId ()
 
 getModelId ()
 

Protected Member Functions

 exists ($name)
 
 assertExists ($name)
 
 getProperties ()
 

Constructor & Destructor Documentation

◆ __construct()

OMV\Config\ConfigObject::__construct (   $id)
Parameters
idThe data model identifier.

Member Function Documentation

◆ add()

OMV\Config\ConfigObject::add (   $name,
  $type,
  $default = NULL 
)

Add a new property. This can be accessed by the get/set methods. Note, this will modify the data model of this object. In common this is only useful for scalar types like string, boolean, integer, ...

Parameters
nameThe name of the property in dot notation, e.g. 'a.b.c'.
typeThe type of the property, e.g. 'string' or 'boolean'.
defaultAn optional default value.
Returns
None.

◆ assertExists()

OMV\Config\ConfigObject::assertExists (   $name)
protected

Assert that the specified property exists.

Parameters
nameThe name of the property in dot notation, e.g. 'a.b.c'.
Returns
None.
Exceptions

◆ copy()

OMV\Config\ConfigObject::copy (   $name,
  $targetName 
)

Copy an existing property to another one. The target property will be created if necessary.

Parameters
nameThe name of the property in dot notation, e.g. 'a.b.c'.
targetNameThe name of the target property in dot notation, e.g. 'x.y'.
Returns
None.

◆ createIdentifier()

OMV\Config\ConfigObject::createIdentifier ( )

Create a new object identifier (UUID). Use this method only if the configuration object has an 'uuid' property.

Returns
The new object identifier.
Exceptions

◆ exists()

OMV\Config\ConfigObject::exists (   $name)
protected

Check if the specified property exists.

Parameters
nameThe name of the property in dot notation, e.g. 'a.b.c'.
Returns
Returns TRUE if the property exists, otherwise FALSE.

◆ get()

OMV\Config\ConfigObject::get (   $name)

Get a property.

Parameters
nameThe name of the property in dot notation, e.g. 'a.b.c'.
Returns
The property value.

◆ getAssoc()

OMV\Config\ConfigObject::getAssoc ( )

Get all properties as an associative array. Example:

Array
(
[timezone] => Europe/Berlin
[ntp] => Array
(
[enable] => 1
[timeservers] => pool.ntp.org,pool1.ntp.org;pool2.ntp.org,sss
)
)
Returns
The array of key/value pairs.

◆ getDefaultsAssoc()

OMV\Config\ConfigObject::getDefaultsAssoc ( )

Get the default properties as an associative array.

Returns
The array of key/value pairs with the default values as described by the data model.

◆ getDefaultsIndexed()

OMV\Config\ConfigObject::getDefaultsIndexed ( )

Get the default properties as an indexed array. The property keys may look like 'a.b.c' or 'shares.share.0.uuid'.

Returns
The array of key/value pairs with the default values as described by the data model.

◆ getId()

OMV\Config\ConfigObject::getId ( )

Get the data model identifier of this configuration object.

Deprecated:
Returns
The data model identifier.

◆ getIdentifier()

OMV\Config\ConfigObject::getIdentifier ( )

Get the object identifier.

Returns
The object identifier.

◆ getIndexed()

OMV\Config\ConfigObject::getIndexed ( )

Get all properties as an array with the keys in dot notation. Example:

[winssupport] =>
[winsserver] =>
[homesenable] =>
[homesbrowseable] => 1
[extraoptions] =>
[shares.share.0.uuid] => 1837f560-2589-47ff-98ba-287dc3b73c3f
[shares.share.0.enable] => 1
[shares.share.0.sharedfolderref] => e03ee0fc-4c82-4bbe-ad2e-2d7f76774be0
[shares.share.0.name] => dfsdfs
[shares.share.0.comment] =>
[shares.share.0.guest] => no
Returns
The array of key/value pairs in dot notation.

◆ getModel()

OMV\Config\ConfigObject::getModel ( )

Get the data model of the configuration object.

Returns
The data model object.

◆ getModelId()

OMV\Config\ConfigObject::getModelId ( )

Get the data model identifier of this configuration object, e.g.

conf.service.rsyncd.module

  • conf.service.ftp.share
  • conf.system.notification.notification
  • conf.system.sharedfolder
    Returns
    The data model identifier.

◆ getProperties()

OMV\Config\ConfigObject::getProperties ( )
protected

Get the properties dictionary.

Returns
The properties dictionary.

◆ isEmpty()

OMV\Config\ConfigObject::isEmpty (   $name)

Determine whether a property value is empty.

Parameters
nameThe name of the property in dot notation, e.g. 'a.b.c'.
Returns
Returns FALSE if the property exists and has a non-empty, non-zero value, otherwise returns TRUE. If the property does not exist an exception is thrown.
Exceptions

◆ isEqual()

OMV\Config\ConfigObject::isEqual (   $name,
  $value 
)

Determine whether a property value and the specified one are equal.

Parameters
nameThe name of the property in dot notation, e.g. 'a.b.c'.
valueThe value to compare.
Returns
Returns TRUE if the property value and the specified one are equal, otherwise FALSE. If the property does not exist an exception is thrown.
Exceptions

◆ isIdentifiable()

OMV\Config\ConfigObject::isIdentifiable ( )

Verify that the configuration object is identifiable.

Returns
Returns TRUE ifthe configuration object is identifiable, FALSE otherwise.

◆ isIterable()

OMV\Config\ConfigObject::isIterable ( )

Verify that the configuration object is iterable.

Returns
Returns TRUE ifthe configuration object is iterable, FALSE otherwise.

◆ isNew()

OMV\Config\ConfigObject::isNew ( )

Check if the configuration object is new. Use this method only if the configuration object has an 'uuid' property.

Returns
TRUE if the configuration object is identified as new, otherwise FALSE.
Exceptions

◆ isReferenceable()

OMV\Config\ConfigObject::isReferenceable ( )

Verify that the configuration object is referenceable.

Returns
Returns TRUE ifthe configuration object is referenceable, FALSE otherwise.

◆ move()

OMV\Config\ConfigObject::move (   $name,
  $targetName 
)

Move an existing property to another one. The target property will be created if necessary. The source property will be removed.

Parameters
nameThe name of the property in dot notation, e.g. 'a.b.c'.
targetNameThe name of the target property in dot notation, e.g. 'x.y'.
Returns
None.

◆ remove()

OMV\Config\ConfigObject::remove (   $name)

Remove/unset the specified property. Note, this will modify the data model of this object.

Parameters
nameThe name of the property in dot notation, e.g. 'a.b.c'.
Returns
None.

◆ reset()

OMV\Config\ConfigObject::reset (   $name)

Reset a property to its default value as defined in the data model.

Parameters
nameThe name of the property in dot notation, e.g. 'a.b.c'.
Returns
None.

◆ set()

OMV\Config\ConfigObject::set (   $name,
  $value,
  $validate = TRUE 
)

Set a property.

Parameters
nameThe name of the property in dot notation, e.g. 'a.b.c'.
valueThe value of the property.
Returns
None.

◆ setAssoc()

OMV\Config\ConfigObject::setAssoc ( array  $data,
  $validate = TRUE,
  $ignore = FALSE 
)

Set properties. Example:

array(
"c" => "d",
"a" => [
"b" => [
"c" => 1
]
],
"x" => [
"x" => "z",
"y" => [
0 => [
a => "xxx",
b => "yyy"
],
1 => [
a => "aaa",
b => "bbb"
]
]
]
)
Parameters
array$dataThe associative array of key/value pairs.
bool$validateSet to FALSE to do not validate the property values against the property schema defined in the model. Defaults to TRUE.
bool$ignoreSet to TRUE to ignore and skip unknown properties. Defaults to FALSE.
Returns
None.

◆ setDefaults()

OMV\Config\ConfigObject::setDefaults ( )

Set the default property values as defined in the data model.

Returns
None.

◆ setFlatAssoc()

OMV\Config\ConfigObject::setFlatAssoc ( array  $data,
  $validate = TRUE,
  $ignore = FALSE 
)

Set properties. Example:

array(
"c" => "d",
"x.x" => "z",
"a.b.c" => 1,
"x.y.0.a" => "xxx",
"x.y.0.b" => "yyy",
"x.y.1.a" => "aaa",
"x.y.1.b" => "bbb"
)
Parameters
array$dataThe single dimension array of key/value pairs. The key must be in dot notation, e.g. 'a.b.c' or 'a.b.0.c.1'
bool$validateSet to FALSE to do not validate the property values against the property schema defined in the model. Defaults to TRUE.
bool$ignoreSet to TRUE to ignore and skip unknown properties. Defaults to FALSE.
Returns
None.

◆ setIndexed()

OMV\Config\ConfigObject::setIndexed ( array  $data,
  $validate = TRUE,
  $ignore = FALSE 
)

Set properties.

Deprecated:
Parameters
array$dataThe single dimension array of key/value pairs. The key must be in dot notation, e.g. 'a.b.c' or 'a.b.0.c.1'
bool$validateSet to FALSE to do not validate the property values against the property schema defined in the model. Defaults to TRUE.
bool$ignoreSet to TRUE to ignore and skip unknown properties. Defaults to FALSE.
Returns
None.

◆ setNew()

OMV\Config\ConfigObject::setNew ( )

Mark the configuration object as new. The 'uuid' property is modified in this case.

Returns
None.
Exceptions

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