|
| registerMethod ($rpcName, $methodName=NULL) |
|
| registerMethodSequence ($service, $method, $method2) |
|
| validateMethodParams ($params, $schema) |
|
| validateMethodContext ($context, $required) |
|
| getAdminContext () |
|
| fork () |
|
| createBgProcStatus () |
|
| createBgProcOutput ($prefix="bgoutput") |
|
| writeBgProcOutput ($filename, $content) |
|
| initializeBgProcStatus ($filename, $pid) |
|
| finalizeBgProcStatus ($filename, $result=NULL, $exception=NULL) |
|
| updateBgProcStatus ($filename, $key, $value) |
|
| getBgProcStatus ($filename) |
|
| unlinkBgProcStatus ($filename) |
|
| exec ($command, &$output=NULL, $outputFilename=NULL) |
|
| execve ($path, $args=NULL, $outputFilename=NULL) |
|
| applyFilter ($array, $start, $limit, $sortField=NULL, $sortDir=NULL) |
|
| deleteConfigObjectByUuid ($model, $uuid, $notifyId) |
|
| deleteConfigObjectByObject (\OMV\Config\ConfigObject $object, $notifyId) |
|
| setModuleDirty ($name) |
|
| isModuleDirty ($name) |
|
The core RPC service class.
OMV\Rpc\ServiceAbstract::applyFilter |
( |
|
$array, |
|
|
|
$start, |
|
|
|
$limit, |
|
|
|
$sortField = NULL , |
|
|
|
$sortDir = NULL |
|
) |
| |
|
finalprotected |
Helper function to filter the method result using the given filter arguments.
- Parameters
-
array | The array of objects to filter. |
start | The index where to start. |
limit | The number of elements to process. |
sortField | The name of the column used to sort. |
sortDir | The sort direction, ASC or DESC. |
- Returns
- An array containing the elements matching the given restrictions. The field total contains the total number of elements, data contains the elements as array. An exception will be thrown in case of an error.
OMV\Rpc\ServiceAbstract::callMethod |
( |
|
$name, |
|
|
|
$params, |
|
|
|
$context |
|
) |
| |
|
final |
Call the given RPC service method. Registered method hooks will be called after the origin method has been successfully called.
- Parameters
-
name | The name of the method. |
params | The method parameters. |
context | The context of the caller. |
- Returns
- Returns the return value of the RPC service method.
OMV\Rpc\ServiceAbstract::callMethodBg |
( |
|
$name, |
|
|
|
$params, |
|
|
|
$context |
|
) |
| |
|
final |
Call the given RPC service method in a background process. Registered method hooks will be called after the origin method has been successfully called.
- Parameters
-
name | The name of the method. |
params | The method parameters. |
context | The context of the caller. |
- Returns
- The name of the background process status file.
OMV\Rpc\ServiceAbstract::createBgProcOutput |
( |
|
$prefix = "bgoutput" | ) |
|
|
finalprotected |
Helper function to create the file containing the background process output.
- Returns
- The name of the background process output file.
- Exceptions
-
OMV\Rpc\ServiceAbstract::createBgProcStatus |
( |
| ) |
|
|
finalprotected |
Helper function to create the file containing the background process status.
- Returns
- The name of the background process status file.
- Exceptions
-
Helper function to delete an configuration object. The notifications OMV_NOTIFY_PREDELETE and OMV_NOTIFY_DELETE will be submitted to its subscribers.
- Deprecated:
- Parameters
-
object | The configuration object. |
notifyId | The notification identifier to be submitted. |
- Returns
- The deleted configuration object.
OMV\Rpc\ServiceAbstract::deleteConfigObjectByUuid |
( |
|
$model, |
|
|
|
$uuid, |
|
|
|
$notifyId |
|
) |
| |
|
protected |
Helper function to delete an configuration object. The notifications OMV_NOTIFY_PREDELETE and OMV_NOTIFY_DELETE will be submitted to its subscribers.
- Deprecated:
- Parameters
-
model | The data model identifier of the configuration object. |
uuid | The UUID of the configuration object. |
notifyId | The notification identifier to be submitted. |
- Returns
- The deleted configuration object.
OMV\Rpc\ServiceAbstract::exec |
( |
|
$command, |
|
|
& |
$output = NULL , |
|
|
|
$outputFilename = NULL |
|
) |
| |
|
finalprotected |
Helper function to execute an external program. The command output will be redirected to the given file if set.
- Parameters
-
command | The command that will be executed. |
output | If the output argument is present, then the specified array will be filled with every line of the command output from stdout. Trailing whitespace, such as
, is not included in this array. |
outputFilename | The name of the file that receives the command output from stdout. If set to NULL the command output will not be redirected to a file. |
- Returns
- The exit code of the command or -1 in case of an error.
OMV\Rpc\ServiceAbstract::execBgProc |
( |
\Closure |
$childProc, |
|
|
\Closure |
$error = NULL , |
|
|
\Closure |
$finally = NULL |
|
) |
| |
Execute the specified anonymous function as a background process by forking the main process.
- Parameters
-
Closure | $childProc | An anonymous function that expects the parameters $bgStatusFilename and $bgOutputFilename. It should return a string with the process output. |
Closure | $error | An anonymous function that expects the parameters $bgStatusFilename and $bgOutputFilename. It will be called in case of an exception within the $childProc closure. |
Closure | $finally | An anonymous function without arguments. It will always be executed after the background process has been finished successfully or it has been failed. |
- Returns
- The name of the background process status file.
OMV\Rpc\ServiceAbstract::execve |
( |
|
$path, |
|
|
|
$args = NULL , |
|
|
|
$outputFilename = NULL |
|
) |
| |
|
finalprotected |
Helper function to executes specified program in current process space.
- Parameters
-
path | The path to a binary executable or a script with a valid path pointing to an executable in the shebang as the first line. |
args | An array of argument strings passed to the program. |
outputFilename | The name of the file that receives the command output from STDOUT. STDERR will be redirected to this file, too. If set to NULL the command output will not be redirected to a file. |
- Returns
- Returns FALSE on error and does not return on success.
OMV\Rpc\ServiceAbstract::finalizeBgProcStatus |
( |
|
$filename, |
|
|
|
$result = NULL , |
|
|
|
$exception = NULL |
|
) |
| |
|
finalprotected |
Helper function to finalize the background process status file.
- Parameters
-
filename | The name of the status file. |
result | The result of the background process, e.g. the output of an executed command. Defaults to NULL. |
exception | The exception that has been thrown. Defaults to NULL. |
- Returns
- The background process status.
OMV\Rpc\ServiceAbstract::fork |
( |
| ) |
|
|
finalprotected |
Helper function to fork the current running process.
- Returns
- The PID of the child process.
- Exceptions
-
OMV\Rpc\ServiceAbstract::getAdminContext |
( |
| ) |
|
|
finalprotected |
Helper function to get the administrator context.
- Returns
- The context object.
OMV\Rpc\ServiceAbstract::getBgProcStatus |
( |
|
$filename | ) |
|
|
finalprotected |
Helper function to get the background process status file content.
- Parameters
-
filename | The name of the status file. |
- Returns
- The background process status.
OMV\Rpc\ServiceAbstract::getName |
( |
| ) |
|
|
abstract |
Get the name of the RPC service.
- Returns
- The name of the RPC service.
OMV\Rpc\ServiceAbstract::hasMethod |
( |
|
$name | ) |
|
|
final |
Check if the given service method exists.
- Returns
- TRUE if the service method exists, otherwise FALSE.
OMV\Rpc\ServiceAbstract::initialize |
( |
| ) |
|
|
abstract |
Initialize the RPC service.
OMV\Rpc\ServiceAbstract::initializeBgProcStatus |
( |
|
$filename, |
|
|
|
$pid |
|
) |
| |
|
finalprotected |
Helper function to update the background process status file.
- Parameters
-
filename | The name of the status file. |
pid | The PID of the background process. |
- Returns
- The background process status.
OMV\Rpc\ServiceAbstract::isModuleDirty |
( |
|
$name | ) |
|
|
finalprotected |
Helper function to check whether a module is marked dirty.
- Parameters
-
name | The name of the module. |
- Returns
- TRUE if the module is marked dirty, otherwise FALSE.
OMV\Rpc\ServiceAbstract::registerMethod |
( |
|
$rpcName, |
|
|
|
$methodName = NULL |
|
) |
| |
|
finalprotected |
Register a RPC service method. Only those methods can be executed via RPC.
- Parameters
-
rpcName | The name of the RPC service method. |
methodName | The name of the class method that implements the RPC sevice method. If set to NULL the name given in rpcName is used. Defaults to NULL. |
- Returns
- TRUE on success, otherwise an error is thrown.
OMV\Rpc\ServiceAbstract::registerMethodSequence |
( |
|
$service, |
|
|
|
$method, |
|
|
|
$method2 |
|
) |
| |
|
finalprotected |
Create a combined RPC service method call sequence of the original method and the passed method. The passed method is called with the parameters of the original RPC service method.
- Parameters
-
service | The name of the RPC service. |
method | The name of the original RPC service method. |
method2 | The name of the method that should be called after the original RPC service method. |
- Returns
- TRUE on success, otherwise an exception is thrown.
OMV\Rpc\ServiceAbstract::setModuleDirty |
( |
|
$name | ) |
|
|
finalprotected |
Helper function to mark a module as dirty.
- Parameters
-
name | The name of the module. |
- Returns
- The list of dirty modules.
OMV\Rpc\ServiceAbstract::unlinkBgProcStatus |
( |
|
$filename | ) |
|
|
finalprotected |
Helper function to unlink the background process status file.
- Parameters
-
filename | The name of the status file. |
- Returns
- None.
OMV\Rpc\ServiceAbstract::updateBgProcStatus |
( |
|
$filename, |
|
|
|
$key, |
|
|
|
$value |
|
) |
| |
|
finalprotected |
Helper function to update informations of the background process status file.
- Parameters
-
filename | The name of the status file. |
key | The name of the field to be modified. |
value | The new value of the field. |
- Returns
- The background process status.
OMV\Rpc\ServiceAbstract::validateMethodContext |
( |
|
$context, |
|
|
|
$required |
|
) |
| |
|
finalprotected |
Helper function to validate the method caller context.
- Parameters
-
context | The caller context to be validated. |
required | The required context. |
- Returns
- None.
- Exceptions
-
OMV\Rpc\ServiceAbstract::validateMethodParams |
( |
|
$params, |
|
|
|
$schema |
|
) |
| |
|
finalprotected |
Helper function to validate the given method parameters using JSON schema.
- Parameters
-
params | The parameters to be validated. |
schema | The JSON schema that describes the method parameters. Can be given as UTF-8 encoded JSON or an associative array. Alternatively this can be the identifier of a data model used for validation. |
- Returns
- None.
OMV\Rpc\ServiceAbstract::writeBgProcOutput |
( |
|
$filename, |
|
|
|
$content |
|
) |
| |
|
finalprotected |
Helper function to write a string to the background process output.
- Parameters
-
filename | Path to the file where to write the content. |
content | The content to write. |
- Returns
- This function returns the number of bytes that were written to the file, or FALSE on failure.
The documentation for this class was generated from the following file: