protected function RestfulBase::processDataProviderOptions in RESTful 7
Process plugin options by validation keys exists, and set default values.
Parameters
array $required_keys: Array of required keys.
array $default_values: Array of default values to populate in the $plugin['data_provider_options'].
Return value
array Array with data provider options populated with default values.
Throws
2 calls to RestfulBase::processDataProviderOptions()
- RestfulDataProviderCToolsPlugins::__construct in plugins/
restful/ RestfulDataProviderCToolsPlugins.php - Constructs a RestfulDataProviderCToolsPlugins object.
- RestfulDataProviderDbQuery::__construct in plugins/
restful/ RestfulDataProviderDbQuery.php - Constructs a RestfulDataProviderDbQuery object.
File
- plugins/
restful/ RestfulBase.php, line 456 - Contains RestfulBase.
Class
- RestfulBase
- Class \RestfulBase
Code
protected function processDataProviderOptions($required_keys = array(), $default_values = array()) {
$options = $this
->getPluginKey('data_provider_options');
$params = array(
'@class' => get_class($this),
);
// Check required keys exist.
foreach ($required_keys as $key) {
if (empty($options[$key])) {
$params['@key'] = $key;
throw new \RestfulServiceUnavailable(format_string('@class is missing "@key" property in the "data_provider_options" key of the $plugin', $params));
}
}
// Add default values.
$options += $default_values;
$this
->setPluginKey('data_provider_options', $options);
return $options;
}