Notes from Thursday AM - Angie Byron, Jeff Eaton, Randy FayBe sure to read http://drupal.org/writing-secure-code - Read it. Love it.Alter hooks - how to totally trick out your Drupal site. hook_X-alter() - what we do when Drupal does it wrong...
// let modules hook myapi_stuff() to add to the list of stuff.
$stuff = module_invoke_all('myapi_stuff');
// let modules alter the stuff
drupal_alter('myapi_stuff', $stuff);
// process the stuff
$results = myapi_process_stuff($stuff);
// let modules react by doing a post-event hook
module_invoke_all('myapi_stuffed', $stuff, $results);
return $results
}
This appears to also be a help toward maintainability - expose your stuff in small bits and write a family of modules to work together? Maybe? Important tips:
- build stuff
- Alter stuff...
- hook_form_alter()
- hook_menu_alter
- hook_link_alter
- hook_mail_alter
- hook_schema_alter
- hook_theme_registry_alter
- lots more
// let modules hook myapi_stuff() to add to the list of stuff.
$stuff = module_invoke_all('myapi_stuff');
// let modules alter the stuff
drupal_alter('myapi_stuff', $stuff);
// process the stuff
$results = myapi_process_stuff($stuff);
// let modules react by doing a post-event hook
module_invoke_all('myapi_stuffed', $stuff, $results);
return $results
}
This appears to also be a help toward maintainability - expose your stuff in small bits and write a family of modules to work together? Maybe? Important tips:
- make a module for reuse if you do stuff the same way on multiple sites.
- NEVER name a module and theme the same thing...ka-BOOM
- be kind to other developers, use unique function names, namespaces, etc.
No comments:
Post a Comment