Providing new entity properties

This screencast shows how you can add information (properties) to the entities known by the Entity API module; in this case by adding the word list to the globally available "site" entity (which is not really an entity). This is done by implementing a hook: hook_entity_property_info_alter. There is also some general information about alter hooks in Drupal. (I accidentally removed the wordlist_get_list() function at the end of the screencast. This is restored in the next screencast. Sorry.) code added to wordlist.module /** * Fetches the list of words as defined by Word list module. * @return * An array of words, not sanitized. */ function wordlist_get_list() { return variable_get('wordlist_words', array()); } /** * Implements hook_entity_property_info_alter(). */ function wordlist_entity_property_info_alter(&$info) { $info['site']['properties']['wordlist_words'] = array( 'label' => t('Word list'), 'description' => t('A list of words, as defined by the Word list module.'), 'getter callback' => 'wordlist_get_list', 'sanitize' => 'check_plain', 'type' => 'list', ); }