features_override.hooks.inc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @file
  4. * Contains implementation of features_override's hooks for other modules.
  5. */
  6. /**
  7. * Implements hook_features_override_component_overrides_alter().
  8. */
  9. function image_features_override_component_overrides_alter(&$default, &$normal, $context) {
  10. if ($context['component'] == 'image') {
  11. // Effects have their keys changed on override. This resets them to numeric.
  12. $normal['effects'] = array_values($normal['effects']);
  13. $default['effects'] = array_values($default['effects']);
  14. }
  15. }
  16. /**
  17. * Implements hook_features_override_export_render_addition() for image.
  18. */
  19. function image_features_override_export_render_addition($alter, $element) {
  20. $code = array();
  21. if (isset($alter['keys']) && isset($alter['value'])) {
  22. $component_start = "\$data['$element']";
  23. $code_line = features_override_export_keys($alter['keys']);
  24. $value_export = features_override_var_export($alter['value'], ' ');
  25. $code[] = "";
  26. $code[] = " if (" . $component_start . "['storage'] == IMAGE_STORAGE_DEFAULT) {";
  27. $code[] = " " . $component_start . $code_line . ' = ' . $value_export . ';';
  28. $code[] = " }";
  29. }
  30. return $code;
  31. }
  32. /**
  33. * Implements hook_features_override_export_render_addition() for image.
  34. */
  35. function image_features_override_export_render_deletion($alter, $element) {
  36. $code = array();
  37. if (isset($alter['keys'])) {
  38. $component_start = "\$data['$element']";
  39. $code_line = features_override_export_keys($alter['keys']);
  40. $code[] = "";
  41. $code[] = " if (" . $component_start . "['storage'] == IMAGE_STORAGE_DEFAULT) {";
  42. $code[] = ' unset(' . $component_start . $code_line . ');';
  43. $code[] = " }";
  44. }
  45. return $code;
  46. }