summaryrefslogtreecommitdiff
path: root/modules/field
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-10-13 16:38:43 +0000
committerDries Buytaert <dries@buytaert.net>2009-10-13 16:38:43 +0000
commitfbfa7a4150a40d6df9347692bb6681f45f804c7d (patch)
tree425db0f6cc7b72b8a9350c5a462fe718e0ed2877 /modules/field
parentf67e438b4196a6bc79c0da576da0a9e09fedb612 (diff)
downloadbrdo-fbfa7a4150a40d6df9347692bb6681f45f804c7d.tar.gz
brdo-fbfa7a4150a40d6df9347692bb6681f45f804c7d.tar.bz2
- Patch #593522 by sun: a better and faster drupal_alter().
Diffstat (limited to 'modules/field')
-rw-r--r--modules/field/field.api.php36
-rw-r--r--modules/field/field.attach.inc15
2 files changed, 30 insertions, 21 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php
index 52673a39c..60e54d5d8 100644
--- a/modules/field/field.api.php
+++ b/modules/field/field.api.php
@@ -932,15 +932,15 @@ function hook_field_attach_presave($obj_type, $object) {
* This hook is invoked while preprocessing the field.tpl.php template file.
*
* @param $variables
- * The variables array is passed by reference and will be populated with field values.
- * @param $obj_type
- * The type of $object; e.g. 'node' or 'user'.
- * @param $object
- * The object with fields to render.
- * @param $element
- * The structured array containing the values ready for rendering.
+ * The variables array is passed by reference and will be populated with field
+ * values.
+ * @param $context
+ * An associative array containing:
+ * - obj_type: The type of $object; e.g. 'node' or 'user'.
+ * - object: The object with fields to render.
+ * - element: The structured array containing the values ready for rendering.
*/
-function hook_field_attach_preprocess_alter(&$variables, $obj_type, $object, $element) {
+function hook_field_attach_preprocess_alter(&$variables, $context) {
}
/**
@@ -1042,18 +1042,16 @@ function hook_field_attach_delete_revision($obj_type, $object) {
*
* This hook is invoked after the field module has performed the operation.
*
- * @param $output
- * The structured content array tree for all of $object's fields.
- * @param $obj_type
- * The type of $object; e.g. 'node' or 'user'.
- * @param $object
- * The object with fields to render.
- * @param $build_mode
- * Build mode, e.g. 'full', 'teaser'...
- * @param $langcode
- * The language in which the field values will be displayed.
+ * @param &$output
+ * The structured content array tree for all of $object's fields.
+ * @param $context
+ * An associative array containing:
+ * - obj_type: The type of $object; e.g. 'node' or 'user'.
+ * - object: The object with fields to render.
+ * - build_mode: Build mode, e.g. 'full', 'teaser'...
+ * - langcode: The language in which the field values will be displayed.
*/
-function hook_field_attach_view_alter($output, $obj_type, $object, $build_mode, $langcode) {
+function hook_field_attach_view_alter(&$output, $context) {
}
/**
diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc
index 01abd6f78..4118a60e1 100644
--- a/modules/field/field.attach.inc
+++ b/modules/field/field.attach.inc
@@ -1193,7 +1193,13 @@ function field_attach_view($obj_type, $object, $build_mode = 'full', $langcode =
$output['#extra_fields'] = field_extra_fields($bundle);
// Let other modules make changes after rendering the view.
- drupal_alter('field_attach_view', $output, $obj_type, $object, $build_mode, $langcode);
+ $context = array(
+ 'obj_type' => $obj_type,
+ 'object' => $object,
+ 'build_mode' => $build_mode,
+ 'langcode' => $langcode,
+ );
+ drupal_alter('field_attach_view', $output, $context);
return $output;
}
@@ -1228,7 +1234,12 @@ function field_attach_preprocess($obj_type, $object, $element, &$variables) {
}
// Let other modules make changes to the $variables array.
- drupal_alter('field_attach_preprocess', $variables, $obj_type, $object, $element);
+ $context = array(
+ 'obj_type' => $obj_type,
+ 'object' => $object,
+ 'element' => $element,
+ );
+ drupal_alter('field_attach_preprocess', $variables, $context);
}
/**