public function StylesDefault::__construct in Styles 6
Same name and namespace in other branches
- 6.2 includes/Styles.inc \StylesDefault::__construct()
- 7.2 includes/Styles.inc \StylesDefault::__construct()
File
- includes/
Styles.inc, line 25 - Styles.inc Base class for Styles.
Class
- StylesDefault
- @file Styles.inc Base class for Styles.
Code
public function __construct($properties = NULL) {
// If we are passed an array, then set the object properties from its keys.
if (isset($properties)) {
$properties = (array) $properties;
// 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);
}
}
}
}