You are here

public function StylesDefault::__construct in Styles 6.2

Same name and namespace in other branches
  1. 6 includes/Styles.inc \StylesDefault::__construct()
  2. 7.2 includes/Styles.inc \StylesDefault::__construct()

File

includes/Styles.inc, line 23
Styles.inc Base class for Styles.

Class

StylesDefault
@file Styles.inc Base class for Styles.

Code

public function __construct($object = NULL, $effects = NULL, $variables = NULL) {

  // If we are passed an array, then set the object properties from its keys.
  if (isset($object)) {
    $properties = (array) $object;

    // Get the array of callable class methods for this object.
    $methods = get_class_methods($this);
    foreach ($properties as $key => $value) {
      $function = 'set_' . $key;
      if (in_array($function, $methods)) {

        // Call $this->set_PROPERTY_KEY($value) if that method exists.
        $this
          ->{$function}($value);
      }
      else {
        $this
          ->set($key, $value);
      }
    }
    $this
      ->set_object($object);
  }
  if (isset($effects)) {
    $this
      ->set_effects($effects);
  }
  if (isset($variables)) {
    $this
      ->set_variables($variables);
  }
}