function example_drupal_valid_path in Coder 7.2
Same name and namespace in other branches
- 7 coder_upgrade/tests/old/samples/example.module \example_drupal_valid_path()
File
- coder_upgrade/
tests/ old/ samples/ example.module, line 2657
Code
function example_drupal_valid_path() {
// Use case 1 - passes variable directly.
if (!menu_valid_path(array(
'link_path' => $form_state['values']['site_frontpage_1'],
))) {
}
// Use case 2: makes one assignment to array variable; passes variable.
// menu_valid_path() -- Change the next line but leave this alone
$item = array(
'link_path' => $form_state['values']['site_frontpage_2A'],
);
if (!menu_valid_path($item)) {
// Throw an error.
}
// Use case 2: makes one assignment to array variable; passes variable.
$item = array(
'link_path' => $form_state['values']['site_frontpage_2B'],
'link_title' => $var,
);
if (!menu_valid_path($item)) {
// Throw an error.
}
// Use case 3: makes multiple assignments to array variable; passes variable.
$item['link_path'] = $form_state['values']['site_frontpage_3'];
// A comment to mess up things.
$item['link_title'] = $var;
if (!menu_valid_path($item)) {
// Throw an error.
}
// Use case 4 - passes more complex variable directly. (NOT HANDLED)
if (!menu_valid_path($item->xx)) {
// Throw an error.
}
if (!menu_valid_path($item['xx'])) {
// Throw an error.
}
}