function RulesPlugin::checkParameterSettings

Checks whether parameters are correctly configured.

1 call to RulesPlugin::checkParameterSettings()
RulesPlugin::integrityCheck in includes/rules.core.inc
Makes sure the plugin is configured right.

File

includes/rules.core.inc, line 915

Class

RulesPlugin
Base class for rules plugins.

Code

protected function checkParameterSettings() {
    foreach ($this->pluginParameterInfo() as $name => $info) {
        if (isset($info['restriction']) && $info['restriction'] == 'selector' && isset($this->settings[$name])) {
            throw new RulesIntegrityException(t("The parameter %name may only be configured using a selector.", array(
                '%name' => $name,
            )), array(
                $this,
                'parameter',
                $name,
            ));
        }
        elseif (isset($info['restriction']) && $info['restriction'] == 'input' && isset($this->settings[$name . ':select'])) {
            throw new RulesIntegrityException(t("The parameter %name may not be configured using a selector.", array(
                '%name' => $name,
            )), array(
                $this,
                'parameter',
                $name,
            ));
        }
        elseif (!empty($this->settings[$name . ':select']) && !$this->applyDataSelector($this->settings[$name . ':select'])) {
            throw new RulesIntegrityException(t("Data selector %selector for parameter %name is invalid.", array(
                '%selector' => $this->settings[$name . ':select'],
                '%name' => $name,
            )), array(
                $this,
                'parameter',
                $name,
            ));
        }
        elseif ($arg_info = $this->getArgumentInfo($name)) {
            // If we have enough metadata, check whether the types match.
            if (!RulesData::typesMatch($arg_info, $info)) {
                throw new RulesIntegrityException(t("The data type of the configured argument does not match the parameter's %name requirement.", array(
                    '%name' => $name,
                )), array(
                    $this,
                    'parameter',
                    $name,
                ));
            }
        }
        elseif (!$this->isRoot() && !isset($this->settings[$name]) && empty($info['optional']) && $info['type'] != 'hidden') {
            throw new RulesIntegrityException(t('Missing configuration for parameter %name.', array(
                '%name' => $name,
            )), array(
                $this,
                'parameter',
                $name,
            ));
        }
        // @todo Make sure used values are allowed.
        // (key/value pairs + allowed values).
    }
}