diff --git a/features.api.php b/features.api.php index 4fb810e7e173f811bc794b23b2bd2c79d9a68b78..66a025030630b9b1900915be45384dba205584de 100644 --- a/features.api.php +++ b/features.api.php @@ -40,6 +40,14 @@ * 'base': Optional. An alternative base key to use when calling features * hooks for this component. Can be used for features component types that * are declared "dynamically" or are part of a family of components. + * + * 'alter_type': What type of alter hook this hook uses. 'normal' is called + * after the main hook is called. 'inline' is embeded within the default hook + * and may not be implemented by some default hooks. + * 'none' is no alter hook exists. Defaults to 'normal' + * + * 'alter_hook': What the name of the alter hook for this component is. + * Do not include the '_alter' part. Defaults to 'default_hook'. */ function hook_features_api() { return array( diff --git a/features.export.inc b/features.export.inc index 0f778ffc9bd25b80a9d6cc77b6ab5a66e167a133..5aec5df587ba8b6bd525f081795897be64faae33 100644 --- a/features.export.inc +++ b/features.export.inc @@ -354,6 +354,16 @@ function features_get_default_hooks($component = NULL, $reset = FALSE) { return features_get_components($component, 'default_hook', $reset); } +/** + * Gets the available default hooks keyed by components. + */ +function features_get_default_alter_hook($component) { + $default_hook = features_get_components($component, 'default_hook'); + $alter_hook = features_get_components($component, 'alter_hook'); + $alter_type = features_get_components($component, 'alter_type'); + return empty($alter_type) || $alter_type != 'none' ? ($alter_hook ? $alter_hook : $default_hook) : FALSE; +} + /** * Return a code string representing an implementation of a defaults module hook. */ @@ -655,8 +665,11 @@ function features_get_default($component, $module_name = NULL, $alter = TRUE, $r else { if ($default_hook && module_hook($m, $default_hook)) { $cache[$component][$m] = call_user_func("{$m}_{$default_hook}"); - if ($alter) { - drupal_alter($default_hook, $cache[$component][$m]); + $alter_type = features_get_components('alter_type', $component); + if ($alter && (!isset($alter_type) || $alter_type == FEATURES_ALTER_TYPE_NORMAL)) { + if ($alter_hook = features_get_default_alter_hook($component)) { + drupal_alter($alter_hook, $cache[$component][$m]); + } } } else { diff --git a/features.module b/features.module index 9bcfea0d8b46745d748b83dd859e184a5507cefa..300241c0ce2e32a9e2ea2fb86e7bb8800c2f6f64 100644 --- a/features.module +++ b/features.module @@ -18,6 +18,9 @@ define('FEATURES_NEEDS_REVIEW', 2); define('FEATURES_REBUILDING', 3); define('FEATURES_CONFLICT', 4); define('FEATURES_DISABLED', 5); +define('FEATURES_ALTER_TYPE_NORMAL', 'normal'); +define('FEATURES_ALTER_TYPE_INLINE', 'inline'); +define('FEATURES_ALTER_TYPE_NONE', 'none'); // Duration of rebuild semaphore: 10 minutes. define('FEATURES_SEMAPHORE_TIMEOUT', 10 * 60); diff --git a/includes/features.image.inc b/includes/features.image.inc index 713a93a6af9a7e13361b8fd3d2aacb24a0c1e5d5..9eee8db9587d4576e4cca43187eb6ff9288065ae 100644 --- a/includes/features.image.inc +++ b/includes/features.image.inc @@ -9,6 +9,7 @@ function image_features_api() { 'name' => t('Image styles'), 'feature_source' => TRUE, 'default_hook' => 'image_default_styles', + 'alter_hook' => 'image_styles', ) ); }