From fbfa7a4150a40d6df9347692bb6681f45f804c7d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 13 Oct 2009 16:38:43 +0000 Subject: - Patch #593522 by sun: a better and faster drupal_alter(). --- modules/simpletest/tests/common_test.module | 32 ++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'modules/simpletest/tests/common_test.module') diff --git a/modules/simpletest/tests/common_test.module b/modules/simpletest/tests/common_test.module index f7abf51b6..74866f098 100644 --- a/modules/simpletest/tests/common_test.module +++ b/modules/simpletest/tests/common_test.module @@ -10,7 +10,6 @@ * Implement hook_menu(). */ function common_test_menu() { - $items = array(); $items['common-test/drupal_goto'] = array( 'title' => 'Drupal Goto', 'page callback' => 'common_test_drupal_goto_land', @@ -70,6 +69,37 @@ function common_test_drupal_goto_alter(&$args) { } } +/** + * Implement hook_TYPE_alter(). + */ +function common_test_drupal_alter_alter(&$data, &$arg2 = NULL, &$arg3 = NULL) { + // Alter first argument. + if (is_array($data)) { + $data['foo'] = 'Drupal'; + } + elseif (is_object($data)) { + $data->foo = 'Drupal'; + } + // Alter second argument, if present. + if (isset($arg2)) { + if (is_array($arg2)) { + $arg2['foo'] = 'Drupal'; + } + elseif (is_object($arg2)) { + $arg2->foo = 'Drupal'; + } + } + // Try to alter third argument, if present. + if (isset($arg3)) { + if (is_array($arg3)) { + $arg3['foo'] = 'Drupal'; + } + elseif (is_object($arg3)) { + $arg3->foo = 'Drupal'; + } + } +} + /** * Implement hook_theme(). */ -- cgit v1.2.3