public function add_dependency(base_setting $dependentsetting, $type=null, $options=array()) {
        if ($this->is_circular_reference($dependentsetting)) {
            $a = new stdclass();
            $a->alreadydependent = $this->name;
            $a->main = $dependentsetting->get_name();
            throw new base_setting_exception('setting_circular_reference', $a);
        }
        // Check the settings hasn't been already added
        if (array_key_exists($dependentsetting->get_name(), $this->dependencies)) {
            throw new base_setting_exception('setting_already_added');
        }

        $options = (array)$options;

        if (!array_key_exists('defaultvalue', $options)) {
            $options['defaultvalue'] = false;
        }

        if ($type == null) {
            switch ($this->vtype) {
                case self::IS_BOOLEAN :
                    if ($this->get_ui_type() == self::UI_HTML_CHECKBOX) {
                        if ($this->value) {
                            $type = setting_dependency::DISABLED_NOT_CHECKED;
                        } else {
                            $type = setting_dependency::DISABLED_CHECKED;
                        }
                    } else {
                        if ($this->value) {
                            $type = setting_dependency::DISABLED_FALSE;
                        } else {
                            $type = setting_dependency::DISABLED_TRUE;
                        }
                    }
                    break;
                case self::IS_FILENAME :
                case self::IS_PATH :
                case self::IS_INTEGER :
                default :
                    $type = setting_dependency::DISABLED_VALUE;
                    break;
            }
        }

        switch ($type) {
            case setting_dependency::DISABLED_VALUE :
                if (!array_key_exists('value', $options)) {
                    throw new base_setting_exception('dependency_needs_value');
                }
                $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, $options['value'], $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_TRUE :
                $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, true, $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_FALSE :
                $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, false, $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_CHECKED :
                $dependency = new setting_dependency_disabledif_checked($this, $dependentsetting, $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_NOT_CHECKED :
                $dependency = new setting_dependency_disabledif_not_checked($this, $dependentsetting, $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_EMPTY :
                $dependency = new setting_dependency_disabledif_empty($this, $dependentsetting, $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_NOT_EMPTY :
                $dependency = new setting_dependency_disabledif_not_empty($this, $dependentsetting, $options['defaultvalue']);
                break;
        }
        $this->dependencies[$dependentsetting->get_name()] = $dependency;
        $dependency->get_dependent_setting()->register_dependent_dependency($dependency);
    }
public function add_dependency(base_setting $dependentsetting, $type=null, $options=array()) {
        if ($this->is_circular_reference($dependentsetting)) {
            $a = new stdclass();
            $a->alreadydependent = $this->name;
            $a->main = $dependentsetting->get_name();
            throw new base_setting_exception('setting_circular_reference', $a);
        }
        // Check the settings hasn't been already added
        if (array_key_exists($dependentsetting->get_name(), $this->dependencies)) {
            throw new base_setting_exception('setting_already_added');
        }

        $options = (array)$options;

        if (!array_key_exists('defaultvalue', $options)) {
            $options['defaultvalue'] = false;
        }

        if ($type == null) {
            switch ($this->vtype) {
                case self::IS_BOOLEAN :
                    if ($this->get_ui_type() == self::UI_HTML_CHECKBOX) {
                        if ($this->value) {
                            $type = setting_dependency::DISABLED_NOT_CHECKED;
                        } else {
                            $type = setting_dependency::DISABLED_CHECKED;
                        }
                    } else {
                        if ($this->value) {
                            $type = setting_dependency::DISABLED_FALSE;
                        } else {
                            $type = setting_dependency::DISABLED_TRUE;
                        }
                    }
                    break;
                case self::IS_FILENAME :
                case self::IS_PATH :
                case self::IS_INTEGER :
                default :
                    $type = setting_dependency::DISABLED_VALUE;
                    break;
            }
        }

        switch ($type) {
            case setting_dependency::DISABLED_VALUE :
                if (!array_key_exists('value', $options)) {
                    throw new base_setting_exception('dependency_needs_value');
                }
                $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, $options['value'], $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_TRUE :
                $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, true, $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_FALSE :
                $dependency = new setting_dependency_disabledif_equals($this, $dependentsetting, false, $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_CHECKED :
                $dependency = new setting_dependency_disabledif_checked($this, $dependentsetting, $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_NOT_CHECKED :
                $dependency = new setting_dependency_disabledif_not_checked($this, $dependentsetting, $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_EMPTY :
                $dependency = new setting_dependency_disabledif_empty($this, $dependentsetting, $options['defaultvalue']);
                break;
            case setting_dependency::DISABLED_NOT_EMPTY :
                $dependency = new setting_dependency_disabledif_not_empty($this, $dependentsetting, $options['defaultvalue']);
                break;
        }
        $this->dependencies[$dependentsetting->get_name()] = $dependency;
        $dependency->get_dependent_setting()->register_dependent_dependency($dependency);
    }
public function add_dependency ( base_setting $ dependentsetting , $ type = null , $ options = array ( ) ) { if ( $ this -> is_circular_reference ( $ dependentsetting ) ) { $ a = new stdclass ( ) ; $ a -> alreadydependent = $ this -> name ; $ a -> main = $ dependentsetting -> get_name ( ) ; throw new base_setting_exception ( 'setting_circular_reference' , $ a ) ; } // Check the settings hasn't been already added if ( array_key_exists ( $ dependentsetting -> get_name ( ) , $ this -> dependencies ) ) { throw new base_setting_exception ( 'setting_already_added' ) ; } $ options = ( array ) $ options ; if ( ! array_key_exists ( 'defaultvalue' , $ options ) ) { $ options [ 'defaultvalue' ] = false ; } if ( $ type == null ) { switch ( $ this -> vtype ) { case self :: IS_BOOLEAN : if ( $ this -> get_ui_type ( ) == self :: UI_HTML_CHECKBOX ) { if ( $ this -> value ) { $ type = setting_dependency :: DISABLED_NOT_CHECKED ; } else { $ type = setting_dependency :: DISABLED_CHECKED ; } } else { if ( $ this -> value ) { $ type = setting_dependency :: DISABLED_FALSE ; } else { $ type = setting_dependency :: DISABLED_TRUE ; } } break ; case self :: IS_FILENAME : case self :: IS_PATH : case self :: IS_INTEGER : default : $ type = setting_dependency :: DISABLED_VALUE ; break ; } } switch ( $ type ) { case setting_dependency :: DISABLED_VALUE : if ( ! array_key_exists ( 'value' , $ options ) ) { throw new base_setting_exception ( 'dependency_needs_value' ) ; } $ dependency = new setting_dependency_disabledif_equals ( $ this , $ dependentsetting , $ options [ 'value' ] , $ options [ 'defaultvalue' ] ) ; break ; case setting_dependency :: DISABLED_TRUE : $ dependency = new setting_dependency_disabledif_equals ( $ this , $ dependentsetting , true , $ options [ 'defaultvalue' ] ) ; break ; case setting_dependency :: DISABLED_FALSE : $ dependency = new setting_dependency_disabledif_equals ( $ this , $ dependentsetting , false , $ options [ 'defaultvalue' ] ) ; break ; case setting_dependency :: DISABLED_CHECKED : $ dependency = new setting_dependency_disabledif_checked ( $ this , $ dependentsetting , $ options [ 'defaultvalue' ] ) ; break ; case setting_dependency :: DISABLED_NOT_CHECKED : $ dependency = new setting_dependency_disabledif_not_checked ( $ this , $ dependentsetting , $ options [ 'defaultvalue' ] ) ; break ; case setting_dependency :: DISABLED_EMPTY : $ dependency = new setting_dependency_disabledif_empty ( $ this , $ dependentsetting , $ options [ 'defaultvalue' ] ) ; break ; case setting_dependency :: DISABLED_NOT_EMPTY : $ dependency = new setting_dependency_disabledif_not_empty ( $ this , $ dependentsetting , $ options [ 'defaultvalue' ] ) ; break ; } $ this -> dependencies [ $ dependentsetting -> get_name ( ) ] = $ dependency ; $ dependency -> get_dependent_setting ( ) -> register_dependent_dependency ( $ dependency ) ; }
Quick method to add a dependency to this setting.

The dependency created is done so by inspecting this setting and the
setting that is passed in as the dependent setting.

@param base_setting $dependentsetting
@param int $type One of setting_dependency::*
@param array $options
Quick method to add a dependency to this setting .