You are here

function spaces_preset_enforce in Spaces 6

Same name and namespace in other branches
  1. 5.2 spaces.module \spaces_preset_enforce()
  2. 6.2 spaces.module \spaces_preset_enforce()

Enforces a spaces preset.

5 calls to spaces_preset_enforce()
spaces_basic_form_submit in ./spaces_admin.inc
spaces_features_form in ./spaces_admin.inc
spaces_load in ./spaces.module
Load a space.
spaces_preset_form in ./spaces_admin.inc
Form for adding or editing a spaces preset.
spaces_save in ./spaces.module
Saves a space object's feature/setting values.

File

./spaces.module, line 1079

Code

function spaces_preset_enforce(&$space) {
  $presets = spaces_presets($space->type);
  if (isset($space->preset) && isset($presets[$space->preset])) {
    $preset = $presets[$space->preset]['preset'];

    // Enforce features, settings, customizer
    $keys = array(
      'features',
      'settings',
      'customizer',
    );
    foreach ($keys as $key) {
      if (isset($preset[$key]) && is_array($preset[$key])) {
        foreach ($preset[$key] as $k => $v) {
          if ($preset['locked'][$key][$k] || !isset($space->{$key}[$k])) {
            $space->{$key}[$k] = $v;
          }
        }
      }
    }

    // Type-specific presets
    $space
      ->preset_enforce($preset);
  }
}