function patterns_get_pattern_obj in Patterns 7
Same name and namespace in other branches
- 7.2 patterns.module \patterns_get_pattern_obj()
Constructs a Pattern object with default standard values.
Parameters
array $pattern Input array structure of the pattern. Defaults to an empty array.:
Return value
StdClass $pattern The result object.
3 calls to patterns_get_pattern_obj()
- patterns_editor in includes/
forms/ editor.inc - Builds up a pattern editing environment. Loads additional javascript libraries, and supplies AJAX validation on the fly.
- patterns_io_load_pattern_from_file in includes/
io/ io.inc - Creates a pattern object from a file
- patterns_quickrun_submit in includes/
forms/ quickrun.inc - Form submission handler for patterns_quickrun().
File
- ./
patterns.module, line 852
Code
function patterns_get_pattern_obj($pattern = array()) {
$pattern = is_object($pattern) ? $pattern : (object) $pattern;
$defaults = array(
'pid' => '',
'name' => '',
'status' => 0,
// disabled
'public' => 0,
'updated' => '',
// when enabled
'enabled' => '',
// when enabled
'title' => t('New Pattern'),
'pattern' => '',
);
foreach ($defaults as $key => $value) {
if (!isset($pattern->{$key})) {
$pattern->{$key} = $value;
}
}
return $pattern;
}