示例#1
0
/**
 * Invokes a hook in all enabled modules that implement it.
 *
 * @param $hook
 *   The name of the hook to invoke.
 * @param ...
 *   Arguments to pass to the hook.
 *
 * @return
 *   An array of return values of the hook implementations. If modules return
 *   arrays from their implementations, those are merged into one array.
 */
function module_invoke_all($hook)
{
    // This should turn into a link.
    theme('foo', $data);
    // This should not turn into a link.
    sample_function();
}
示例#2
0
/**
 * An excluded function that should not be in the package.
 */
function excluded_function()
{
    // This is for testing whether we can exclude "drupalisms" from this file.
    $baz = theme('sample_two', $foo);
    // But this should make a link.
    $foo = sample_function();
}
示例#3
0
/**
 * A second sample function.
 *
 * This function links to the first sample function, with both see and link,
 * to verify that links work across projects. The see link is at the bottom.
 * Here is the link:
 * @link samp_GRP-6.x Link to the samples group @endlink
 *
 * Here we use the sample_in_code_links(), $sample_global, SAMPLE_CONSTANT in
 * the text. These should all turn into links. So should a reference to the
 * sample.php file.
 *
 * @see sample_in_code_links()
 */
function second_sample_function()
{
    // Use global variable, constant, and function from the sample project in the
    // function body and verify that they turn into links.
    global $sample_global;
    $sample_global = SAMPLE_CONSTANT;
    $foo = sample_function('a', 'b');
}
示例#4
0
/**
 * Does something interesting, to test in-code linking.
 */
function sample_in_code_links()
{
    // Should link to function.
    $foo = sample_function();
    // Should link to theme function.
    $bar = theme('sample_one', $foo);
    // Should link to theme template, not function, though both exist.
    $baz = theme('sample_two', $foo);
    // Should link to theme template.
    $boo = theme('sample_three');
    // Should link to the sample_four theme function.
    $bop = theme('sample_four__option', $foo);
    // Should link to hook.
    $x = module_invoke_all('sample_name', $foo, $baz);
    $stuff = '';
    // Should link to hook.
    foreach (module_implements('sample_name') as $module) {
        // Should link to hook. Note that the variable name has to be $module for
        // this link to work.
        module_invoke($module, 'sample_name', $baz);
    }
    // Should link to alter hook.
    $xx = drupal_alter('another_sample', $foo);
    // Should link to search for this function.
    $z = duplicate_function();
    // Should link to class.
    $j = new SubSample();
    // Should link to constant.
    $k = SAMPLE_CONSTANT;
    // Should link to search for this constant.
    $l = DUPLICATE_CONSTANT;
    $menu = array('title' => 'A title goes here.', 'page callback' => 'sample_function');
    // Functions that don't exist, so should not be linked, but
    // should still be visible.
    $a = nonexistent_function($a, $b);
    $b = module_invoke_all('nonexistent_hook', $foo);
    $c = theme('nonexistent_theme_hook', $foo);
    foreach (module_implements('nonexistent_hook') as $module) {
        module_invoke($module, 'nonexistent_hook', $foo);
    }
    $d = drupal_alter('nonexistent_alter_name', $foo);
}
示例#5
0
 public function testDeprecatedAndError()
 {
     $this->assertType('int', 3);
     sample_function();
 }
示例#6
0
/**
 * Function with the same name as a theme hook.
 */
function sample_one()
{
    // This should turn into a link to the theme function, , and the theme
    // function should reference this function as an invoker.
    theme('sample_one');
    $foo = sample_function();
}
示例#7
0
 public function testWithDeepError()
 {
     sample_function();
     $this->assertEquals(1, 2);
 }