Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -0,0 +1,31 @@
<?php
/**
* @file
* Admin page callbacks for the {{ name }} module.
*/
/**
* Form constructor for the main {{ name }} administration form.
*/
function {{ machine_name }}_settings_form($form, &$form_state) {
$form['{{ machine_name }}_setting_1'] = array(
'#type' => 'textfield',
'#title' => t('Setting 1'),
'#default_value' => variable_get('{{ machine_name }}_setting_1'),
);
$form['{{ machine_name }}_setting_2'] = array(
'#type' => 'select',
'#title' => t('Setting 1'),
'#options' => array(t('Option 1'), t('Option 2'), t('Option 3')),
'#default_value' => variable_get('{{ machine_name }}_setting_2'),
);
$form['{{ machine_name }}_setting_3'] = array(
'#type' => 'checkbox',
'#title' => t('Setting 3'),
'#default_value' => variable_get('{{ machine_name }}_setting_3'),
);
return system_settings_form($form);
}

View file

@ -0,0 +1,53 @@
<?php
/**
* @file
* {{ plugin_name }} access plugin.
*/
/**
* Plugin definition.
*/
$plugin = array(
'single' => TRUE,
'title' => t('{{ plugin_name }}'),
'description' => t('{{ description }}'),
{% if context == 'Node' or context == 'User' %}
'required context' => new ctools_context_required(t('{{ context }}'), '{{ context|lower }}'),
{% elseif context == 'Term' %}
'required context' => new ctools_context_required(t('{{ context }}'), array('term', 'taxonomy_term')),
{% endif %}
'category' => t('{{ category }}'),
'callback' => '{{ machine_name }}_{{ plugin_machine_name }}_access_check',
'summary' => '{{ machine_name }}_{{ plugin_machine_name }}_access_summary',
);
/**
* Access callback.
*/
function {{ machine_name }}_{{ plugin_machine_name }}_access_check($conf, $context) {
{% if context != '-' %}
if (empty($context->data)) {
return;
}
{% endif %}
{% if context == 'Node' or context == 'Term' %}
${{ context|lower }} = clone $context->data;
{% elseif context == 'User' %}
{# Use $account variable avoid confusion with the global $user object #}
$account = clone $context->data;
{% endif %}
// @TODO: Check access here.
return TRUE;
}
/**
* Summary callback.
*/
function {{ machine_name }}_{{ plugin_machine_name }}_access_summary($conf, $context) {
return t('Summary placeholder');
}

View file

@ -0,0 +1,52 @@
<?php
/**
* @file
* {{ plugin_name }} content type plugin.
*/
/**
* Plugin definition.
*/
$plugin = array(
'single' => TRUE,
'title' => t('{{ plugin_name }}'),
'description' => t('{{ description }}'),
{% if context == 'Node' or context == 'User' %}
'required context' => new ctools_context_required(t('{{ context }}'), '{{ context|lower }}'),
{% elseif context == 'Term' %}
'required context' => new ctools_context_required(t('{{ context }}'), array('term', 'taxonomy_term')),
{% endif %}
'category' => t('{{ category }}'),
'render callback' => '{{ machine_name }}_{{ plugin_machine_name }}_content_type_render',
);
/**
* Render callback.
*/
function {{ machine_name }}_{{ plugin_machine_name }}_content_type_render($subtype, $conf, $panel_args, $context) {
{% if context != '-' %}
if (empty($context->data)) {
return;
}
{% endif %}
{% if context == 'Node' or context == 'Term' %}
${{ context|lower }} = clone $context->data;
{% elseif context == 'User' %}
{# Use $account variable to avoid confusion with the global $user object #}
$account = clone $context->data;
{% endif %}
// Build pane content.
$build = array(
'#markup' => 'Content placeholder.',
);
$block = new stdClass();
$block->module = '{{ machine_name }}';
$block->title = t('Title placeholder');
$block->content = $build;
return $block;
}

View file

@ -0,0 +1,44 @@
<?php
/**
* @file
* {{ plugin_name }} relationship plugin.
*/
/**
* Plugin definition.
*/
$plugin = array(
'title' => t('{{ plugin_name }}'),
'description' => t('{{ description }}'),
{% if context == 'Node' or context == 'User' %}
'required context' => new ctools_context_required(t('{{ context }}'), '{{ context|lower }}'),
{% elseif context == 'Term' %}
'required context' => new ctools_context_required(t('{{ context }}'), array('term', 'taxonomy_term')),
{% endif %}
'context' => '{{ machine_name }}_{{ plugin_machine_name }}_context',
);
/**
* Returns a new context based on an existing context.
*/
function {{ machine_name }}_{{ plugin_machine_name }}_context($context, $conf) {
// @TODO: Replace "node" with identifier of the context
// this plugin is meant to provide.
if (empty($context->data)) {
return ctools_context_create_empty('node', NULL);
}
{% if context == 'Node' or context == 'Term' %}
${{ context|lower }} = clone $context->data;
{% elseif context == 'User' %}
{# Use $account variable avoid confusion with the global $user object #}
$account = clone $context->data;
{% endif %}
// @TODO: Replace this code with your own.
$related_node = node_load(1);
return ctools_context_create('node', $related_node);
}

View file

@ -0,0 +1,6 @@
<?php
/**
* @file
* Install, update and uninstall functions for the {{ name }} module.
*/

View file

@ -0,0 +1,6 @@
<?php
/**
* @file
* Primary module hooks for {{ name }} module.
*/

View file

@ -0,0 +1,6 @@
<?php
/**
* @file
* Builds tokens for the {{ name }} module.
*/

View file

@ -0,0 +1,27 @@
/**
* Implements hook_action_info().
*/
function {{ machine_name }}_action_info() {
return array(
'comment_unpublish_action' => array(
'type' => 'comment',
'label' => t('Unpublish comment'),
'configurable' => FALSE,
'behavior' => array('changes_property'),
'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
),
'comment_unpublish_by_keyword_action' => array(
'type' => 'comment',
'label' => t('Unpublish comment containing keyword(s)'),
'configurable' => TRUE,
'behavior' => array('changes_property'),
'triggers' => array('comment_presave', 'comment_insert', 'comment_update'),
),
'comment_save_action' => array(
'type' => 'comment',
'label' => t('Save comment'),
'configurable' => FALSE,
'triggers' => array('comment_insert', 'comment_update'),
),
);
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_action_info_alter().
*/
function {{ machine_name }}_action_info_alter(&$actions) {
$actions['node_unpublish_action']['label'] = t('Unpublish and remove from public view.');
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_actions_delete().
*/
function {{ machine_name }}_actions_delete($aid) {
db_delete('actions_assignments')
->condition('aid', $aid)
->execute();
}

View file

@ -0,0 +1,10 @@
/**
* Implements hook_admin_paths().
*/
function {{ machine_name }}_admin_paths() {
$paths = array(
'mymodule/*/add' => TRUE,
'mymodule/*/edit' => TRUE,
);
return $paths;
}

View file

@ -0,0 +1,10 @@
/**
* Implements hook_admin_paths_alter().
*/
function {{ machine_name }}_admin_paths_alter(&$paths) {
// Treat all user pages as administrative.
$paths['user'] = TRUE;
$paths['user/*'] = TRUE;
// Treat the forum topic node form as a non-administrative page.
$paths['node/add/forum'] = FALSE;
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_aggregator_fetch().
*/
function {{ machine_name }}_aggregator_fetch($feed) {
$feed->source_string = mymodule_fetch($feed->url);
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_aggregator_fetch_info().
*/
function {{ machine_name }}_aggregator_fetch_info() {
return array(
'title' => t('Default fetcher'),
'description' => t('Default fetcher for resources available by URL.'),
);
}

View file

@ -0,0 +1,10 @@
/**
* Implements hook_aggregator_parse().
*/
function {{ machine_name }}_aggregator_parse($feed) {
if ($items = mymodule_parse($feed->source_string)) {
$feed->items = $items;
return TRUE;
}
return FALSE;
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_aggregator_parse_info().
*/
function {{ machine_name }}_aggregator_parse_info() {
return array(
'title' => t('Default parser'),
'description' => t('Default parser for RSS, Atom and RDF feeds.'),
);
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_aggregator_process().
*/
function {{ machine_name }}_aggregator_process($feed) {
foreach ($feed->items as $item) {
mymodule_save($item);
}
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_aggregator_process_info().
*/
function {{ machine_name }}_aggregator_process_info() {
return array(
'title' => t('Default processor'),
'description' => t('Creates lightweight records of feed items.'),
);
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_aggregator_remove().
*/
function {{ machine_name }}_aggregator_remove($feed) {
mymodule_remove_items($feed->fid);
}

View file

@ -0,0 +1,7 @@
/**
* Implements hook_ajax_render_alter().
*/
function {{ machine_name }}_ajax_render_alter(&$commands) {
// Inject any new status messages into the content area.
$commands[] = ajax_command_prepend('#block-system-main .content', theme('status_messages'));
}

View file

@ -0,0 +1,11 @@
/**
* Implements hook_archiver_info().
*/
function {{ machine_name }}_archiver_info() {
return array(
'tar' => array(
'class' => 'ArchiverTar',
'extensions' => array('tar', 'tar.gz', 'tar.bz2'),
),
);
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_archiver_info_alter().
*/
function {{ machine_name }}_archiver_info_alter(&$info) {
$info['tar']['extensions'][] = 'tgz';
}

View file

@ -0,0 +1,15 @@
/**
* Implements hook_batch_alter().
*/
function {{ machine_name }}_batch_alter(&$batch) {
// If the current page request is inside the overlay, add ?render=overlay to
// the success callback URL, so that it appears correctly within the overlay.
if (overlay_get_mode() == 'child') {
if (isset($batch['url_options']['query'])) {
$batch['url_options']['query']['render'] = 'overlay';
}
else {
$batch['url_options']['query'] = array('render' => 'overlay');
}
}
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_block_cid_parts_alter().
*/
function {{ machine_name }}_block_cid_parts_alter(&$cid_parts, $block) {
global $user;
// This example shows how to cache a block based on the user's timezone.
$cid_parts[] = $user->timezone;
}

View file

@ -0,0 +1,16 @@
/**
* Implements hook_block_configure().
*/
function {{ machine_name }}_block_configure($delta = '') {
// This example comes from node.module.
$form = array();
if ($delta == 'recent') {
$form['node_recent_block_count'] = array(
'#type' => 'select',
'#title' => t('Number of recent content items to display'),
'#default_value' => variable_get('node_recent_block_count', 10),
'#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)),
);
}
return $form;
}

View file

@ -0,0 +1,17 @@
/**
* Implements hook_block_info().
*/
function {{ machine_name }}_block_info() {
// This example comes from node.module.
$blocks['syndicate'] = array(
'info' => t('Syndicate'),
'cache' => DRUPAL_NO_CACHE
);
$blocks['recent'] = array(
'info' => t('Recent content'),
// DRUPAL_CACHE_PER_ROLE will be assumed.
);
return $blocks;
}

View file

@ -0,0 +1,7 @@
/**
* Implements hook_block_info_alter().
*/
function {{ machine_name }}_block_info_alter(&$blocks, $theme, $code_blocks) {
// Disable the login block.
$blocks['user']['login']['status'] = 0;
}

View file

@ -0,0 +1,35 @@
/**
* Implements hook_block_list_alter().
*/
function {{ machine_name }}_block_list_alter(&$blocks) {
global $language, $theme_key;
// This example shows how to achieve language specific visibility setting for
// blocks.
$result = db_query('SELECT module, delta, language FROM {my_table}');
$block_languages = array();
foreach ($result as $record) {
$block_languages[$record->module][$record->delta][$record->language] = TRUE;
}
foreach ($blocks as $key => $block) {
// Any module using this alter should inspect the data before changing it,
// to ensure it is what they expect.
if (!isset($block->theme) || !isset($block->status) || $block->theme != $theme_key || $block->status != 1) {
// This block was added by a contrib module, leave it in the list.
continue;
}
if (!isset($block_languages[$block->module][$block->delta])) {
// No language setting for this block, leave it in the list.
continue;
}
if (!isset($block_languages[$block->module][$block->delta][$language->language])) {
// This block should not be displayed with the active language, remove
// from the list.
unset($blocks[$key]);
}
}
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_block_save().
*/
function {{ machine_name }}_block_save($delta = '', $edit = array()) {
// This example comes from node.module.
if ($delta == 'recent') {
variable_set('node_recent_block_count', $edit['node_recent_block_count']);
}
}

View file

@ -0,0 +1,33 @@
/**
* Implements hook_block_view().
*/
function {{ machine_name }}_block_view($delta = '') {
// This example is adapted from node.module.
$block = array();
switch ($delta) {
case 'syndicate':
$block['subject'] = t('Syndicate');
$block['content'] = array(
'#theme' => 'feed_icon',
'#url' => 'rss.xml',
'#title' => t('Syndicate'),
);
break;
case 'recent':
if (user_access('access content')) {
$block['subject'] = t('Recent content');
if ($nodes = node_get_recent(variable_get('node_recent_block_count', 10))) {
$block['content'] = array(
'#theme' => 'node_recent_block',
'#nodes' => $nodes,
);
} else {
$block['content'] = t('No content available.');
}
}
break;
}
return $block;
}

View file

@ -0,0 +1,12 @@
/**
* Implements hook_block_view_MODULE_DELTA_alter().
*/
function {{ machine_name }}_block_view_MODULE_DELTA_alter(&$data, $block) {
// This code will only run for a specific block. For example, if MODULE_DELTA
// in the function definition above is set to "mymodule_somedelta", the code
// will only run on the "somedelta" block provided by the "mymodule" module.
// Change the title of the "somedelta" block provided by the "mymodule"
// module.
$data['subject'] = t('New title of the block');
}

View file

@ -0,0 +1,14 @@
/**
* Implements hook_block_view_alter().
*/
function {{ machine_name }}_block_view_alter(&$data, $block) {
// Remove the contextual links on all blocks that provide them.
if (is_array($data['content']) && isset($data['content']['#contextual_links'])) {
unset($data['content']['#contextual_links']);
}
// Add a theme wrapper function defined by the current module to all blocks
// provided by the "somemodule" module.
if (is_array($data['content']) && $block->module == 'somemodule') {
$data['content']['#theme_wrappers'][] = 'mymodule_special_block';
}
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_boot().
*/
function {{ machine_name }}_boot() {
// We need user_access() in the shutdown function. Make sure it gets loaded.
drupal_load('module', 'user');
drupal_register_shutdown_function('devel_shutdown');
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_comment_delete().
*/
function {{ machine_name }}_comment_delete($comment) {
drupal_set_message(t('Comment: @subject has been deleted', array('@subject' => $comment->subject)));
}

View file

@ -0,0 +1,7 @@
/**
* Implements hook_comment_insert().
*/
function {{ machine_name }}_comment_insert($comment) {
// Reindex the node when comments are added.
search_touch_node($comment->nid);
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_comment_load().
*/
function {{ machine_name }}_comment_load($comments) {
$result = db_query('SELECT cid, foo FROM {mytable} WHERE cid IN (:cids)', array(':cids' => array_keys($comments)));
foreach ($result as $record) {
$comments[$record->cid]->foo = $record->foo;
}
}

View file

@ -0,0 +1,7 @@
/**
* Implements hook_comment_presave().
*/
function {{ machine_name }}_comment_presave($comment) {
// Remove leading & trailing spaces from the comment subject.
$comment->subject = trim($comment->subject);
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_comment_publish().
*/
function {{ machine_name }}_comment_publish($comment) {
drupal_set_message(t('Comment: @subject has been published', array('@subject' => $comment->subject)));
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_comment_unpublish().
*/
function {{ machine_name }}_comment_unpublish($comment) {
drupal_set_message(t('Comment: @subject has been unpublished', array('@subject' => $comment->subject)));
}

View file

@ -0,0 +1,7 @@
/**
* Implements hook_comment_update().
*/
function {{ machine_name }}_comment_update($comment) {
// Reindex the node when comments are updated.
search_touch_node($comment->nid);
}

View file

@ -0,0 +1,7 @@
/**
* Implements hook_comment_view().
*/
function {{ machine_name }}_comment_view($comment, $view_mode, $langcode) {
// how old is the comment
$comment->time_ago = time() - $comment->changed;
}

View file

@ -0,0 +1,13 @@
/**
* Implements hook_comment_view_alter().
*/
function {{ machine_name }}_comment_view_alter(&$build) {
// Check for the existence of a field added by another module.
if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
// Change its weight.
$build['an_additional_field']['#weight'] = -10;
}
// Add a #post_render callback to act on the rendered HTML of the comment.
$build['#post_render'][] = 'my_module_comment_post_render';
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_contextual_links_view_alter().
*/
function {{ machine_name }}_contextual_links_view_alter(&$element, $items) {
// Add another class to all contextual link lists to facilitate custom
// styling.
$element['#attributes']['class'][] = 'custom-class';
}

View file

@ -0,0 +1,7 @@
/**
* Implements hook_countries_alter().
*/
function {{ machine_name }}_countries_alter(&$countries) {
// Elbonia is now independent, so add it to the country list.
$countries['EB'] = 'Elbonia';
}

View file

@ -0,0 +1,23 @@
/**
* Implements hook_cron().
*/
function {{ machine_name }}_cron() {
// Short-running operation example, not using a queue:
// Delete all expired records since the last cron run.
$expires = variable_get('mymodule_cron_last_run', REQUEST_TIME);
db_delete('mymodule_table')
->condition('expires', $expires, '>=')
->execute();
variable_set('mymodule_cron_last_run', REQUEST_TIME);
// Long-running operation example, leveraging a queue:
// Fetch feeds from other sites.
$result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < :time AND refresh <> :never', array(
':time' => REQUEST_TIME,
':never' => AGGREGATOR_CLEAR_NEVER,
));
$queue = DrupalQueue::get('aggregator_feeds');
foreach ($result as $feed) {
$queue->createItem($feed);
}
}

View file

@ -0,0 +1,10 @@
/**
* Implements hook_cron_queue_info().
*/
function {{ machine_name }}_cron_queue_info() {
$queues['aggregator_feeds'] = array(
'worker callback' => 'aggregator_refresh',
'time' => 60,
);
return $queues;
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_cron_queue_info_alter().
*/
function {{ machine_name }}_cron_queue_info_alter(&$queues) {
// This site has many feeds so let's spend 90 seconds on each cron run
// updating feeds instead of the default 60.
$queues['aggregator_feeds']['time'] = 90;
}

View file

@ -0,0 +1,7 @@
/**
* Implements hook_css_alter().
*/
function {{ machine_name }}_css_alter(&$css) {
// Remove defaults.css file.
unset($css[drupal_get_path('module', 'system') . '/defaults.css']);
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_custom_theme().
*/
function {{ machine_name }}_custom_theme() {
// Allow the user to request a particular theme via a query parameter.
if (isset($_GET['theme'])) {
return $_GET['theme'];
}
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_dashboard_regions().
*/
function {{ machine_name }}_dashboard_regions() {
// Define a new dashboard region. Your module can also then define
// theme_mymodule_dashboard_region() as a theme wrapper function to control
// the region's appearance.
return array('mymodule_dashboard_region' => "My module's dashboard region");
}

View file

@ -0,0 +1,7 @@
/**
* Implements hook_dashboard_regions_alter().
*/
function {{ machine_name }}_dashboard_regions_alter(&$regions) {
// Remove the sidebar region defined by the core dashboard module.
unset($regions['dashboard_sidebar']);
}

View file

@ -0,0 +1,11 @@
/**
* Implements hook_date_format_types().
*/
function {{ machine_name }}_date_format_types() {
// Define the core date format types.
return array(
'long' => t('Long'),
'medium' => t('Medium'),
'short' => t('Short'),
);
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_date_format_types_alter().
*/
function {{ machine_name }}_date_format_types_alter(&$types) {
foreach ($types as $name => $type) {
$types[$name]['locked'] = 1;
}
}

View file

@ -0,0 +1,22 @@
/**
* Implements hook_date_formats().
*/
function {{ machine_name }}_date_formats() {
return array(
array(
'type' => 'mymodule_extra_long',
'format' => 'l jS F Y H:i:s e',
'locales' => array('en-ie'),
),
array(
'type' => 'mymodule_extra_long',
'format' => 'l jS F Y h:i:sa',
'locales' => array('en', 'en-us'),
),
array(
'type' => 'short',
'format' => 'F Y',
'locales' => array(),
),
);
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_date_formats_alter().
*/
function {{ machine_name }}_date_formats_alter(&$formats) {
foreach ($formats as $id => $format) {
$formats[$id]['locales'][] = 'en-ca';
}
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_delete().
*/
function {{ machine_name }}_delete($node) {
db_delete('mytable')
->condition('nid', $node->nid)
->execute();
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_disable().
*/
function {{ machine_name }}_disable() {
mymodule_cache_rebuild();
}

View file

@ -0,0 +1,7 @@
/**
* Implements hook_drupal_goto_alter().
*/
function {{ machine_name }}_drupal_goto_alter(&$path, &$options, &$http_response_code) {
// A good addition to misery module.
$http_response_code = 500;
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_element_info().
*/
function {{ machine_name }}_element_info() {
$types['filter_format'] = array(
'#input' => TRUE,
);
return $types;
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_element_info_alter().
*/
function {{ machine_name }}_element_info_alter(&$type) {
// Decrease the default size of textfields.
if (isset($type['textfield']['#size'])) {
$type['textfield']['#size'] = 40;
}
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_enable().
*/
function {{ machine_name }}_enable() {
mymodule_cache_rebuild();
}

View file

@ -0,0 +1,12 @@
/**
* Implements hook_entity_delete().
*/
function {{ machine_name }}_entity_delete($entity, $type) {
// Delete the entity's entry from a fictional table of all entities.
$info = entity_get_info($type);
list($id) = entity_extract_ids($type, $entity);
db_delete('example_entity')
->condition('type', $type)
->condition('id', $id)
->execute();
}

View file

@ -0,0 +1,73 @@
/**
* Implements hook_entity_info().
*/
function {{ machine_name }}_entity_info() {
$return = array(
'node' => array(
'label' => t('Node'),
'controller class' => 'NodeController',
'base table' => 'node',
'revision table' => 'node_revision',
'uri callback' => 'node_uri',
'fieldable' => TRUE,
'translation' => array(
'locale' => TRUE,
),
'entity keys' => array(
'id' => 'nid',
'revision' => 'vid',
'bundle' => 'type',
'language' => 'language',
),
'bundle keys' => array(
'bundle' => 'type',
),
'bundles' => array(),
'view modes' => array(
'full' => array(
'label' => t('Full content'),
'custom settings' => FALSE,
),
'teaser' => array(
'label' => t('Teaser'),
'custom settings' => TRUE,
),
'rss' => array(
'label' => t('RSS'),
'custom settings' => FALSE,
),
),
),
);
// Search integration is provided by node.module, so search-related
// view modes for nodes are defined here and not in search.module.
if (module_exists('search')) {
$return['node']['view modes'] += array(
'search_index' => array(
'label' => t('Search index'),
'custom settings' => FALSE,
),
'search_result' => array(
'label' => t('Search result highlighting input'),
'custom settings' => FALSE,
),
);
}
// Bundles must provide a human readable name so we can create help and error
// messages, and the path to attach Field admin pages to.
foreach (node_type_get_names() as $type => $name) {
$return['node']['bundles'][$type] = array(
'label' => $name,
'admin' => array(
'path' => 'admin/structure/types/manage/%node_type',
'real path' => 'admin/structure/types/manage/' . str_replace('_', '-', $type),
'bundle argument' => 4,
'access arguments' => array('administer content types'),
),
);
}
return $return;
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_entity_info_alter().
*/
function {{ machine_name }}_entity_info_alter(&$entity_info) {
// Set the controller class for nodes to an alternate implementation of the
// DrupalEntityController interface.
$entity_info['node']['controller class'] = 'MyCustomNodeController';
}

View file

@ -0,0 +1,16 @@
/**
* Implements hook_entity_insert().
*/
function {{ machine_name }}_entity_insert($entity, $type) {
// Insert the new entity into a fictional table of all entities.
$info = entity_get_info($type);
list($id) = entity_extract_ids($type, $entity);
db_insert('example_entity')
->fields(array(
'type' => $type,
'id' => $id,
'created' => REQUEST_TIME,
'updated' => REQUEST_TIME,
))
->execute();
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_entity_load().
*/
function {{ machine_name }}_entity_load($entities, $type) {
foreach ($entities as $entity) {
$entity->foo = mymodule_add_something($entity, $type);
}
}

View file

@ -0,0 +1,12 @@
/**
* Implements hook_entity_prepare_view().
*/
function {{ machine_name }}_entity_prepare_view($entities, $type, $langcode) {
// Load a specific node into the user object for later theming.
if ($type == 'user') {
$nodes = mymodule_get_user_nodes(array_keys($entities));
foreach ($entities as $uid => $entity) {
$entity->user_node = $nodes[$uid];
}
}
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_entity_presave().
*/
function {{ machine_name }}_entity_presave($entity, $type) {
$entity->changed = REQUEST_TIME;
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_entity_query_alter().
*/
function {{ machine_name }}_entity_query_alter($query) {
$query->executeCallback = 'my_module_query_callback';
}

View file

@ -0,0 +1,15 @@
/**
* Implements hook_entity_update().
*/
function {{ machine_name }}_entity_update($entity, $type) {
// Update the entity's entry in a fictional table of all entities.
$info = entity_get_info($type);
list($id) = entity_extract_ids($type, $entity);
db_update('example_entity')
->fields(array(
'updated' => REQUEST_TIME,
))
->condition('type', $type)
->condition('id', $id)
->execute();
}

View file

@ -0,0 +1,10 @@
/**
* Implements hook_entity_view().
*/
function {{ machine_name }}_entity_view($entity, $type, $view_mode, $langcode) {
$entity->content['my_additional_field'] = array(
'#markup' => $additional_field,
'#weight' => 10,
'#theme' => 'mymodule_my_additional_field',
);
}

View file

@ -0,0 +1,12 @@
/**
* Implements hook_entity_view_alter().
*/
function {{ machine_name }}_entity_view_alter(&$build, $type) {
if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
// Change its weight.
$build['an_additional_field']['#weight'] = -10;
// Add a #post_render callback to act on the rendered HTML of the entity.
$build['#post_render'][] = 'my_module_node_post_render';
}
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_entity_view_mode_alter().
*/
function {{ machine_name }}_entity_view_mode_alter(&$view_mode, $context) {
// For nodes, change the view mode when it is teaser.
if ($context['entity_type'] == 'node' && $view_mode == 'teaser') {
$view_mode = 'my_custom_view_mode';
}
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_exit().
*/
function {{ machine_name }}_exit($destination = NULL) {
db_update('counter')
->expression('hits', 'hits + 1')
->condition('type', 1)
->execute();
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_field_access().
*/
function {{ machine_name }}_field_access($op, $field, $entity_type, $entity, $account) {
if ($field['field_name'] == 'field_of_interest' && $op == 'edit') {
return user_access('edit field of interest', $account);
}
return TRUE;
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_field_attach_create_bundle().
*/
function {{ machine_name }}_field_attach_create_bundle($entity_type, $bundle) {
// When a new bundle is created, the menu needs to be rebuilt to add the
// Field UI menu item tabs.
variable_set('menu_rebuild_needed', TRUE);
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_field_attach_delete().
*/
function {{ machine_name }}_field_attach_delete($entity_type, $entity) {
// @todo Needs function body.
}

View file

@ -0,0 +1,11 @@
/**
* Implements hook_field_attach_delete_bundle().
*/
function {{ machine_name }}_field_attach_delete_bundle($entity_type, $bundle, $instances) {
// Remove the extra weights variable information for this bundle.
$extra_weights = variable_get('field_extra_weights', array());
if (isset($extra_weights[$entity_type][$bundle])) {
unset($extra_weights[$entity_type][$bundle]);
variable_set('field_extra_weights', $extra_weights);
}
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_field_attach_delete_revision().
*/
function {{ machine_name }}_field_attach_delete_revision($entity_type, $entity) {
// @todo Needs function body.
}

View file

@ -0,0 +1,11 @@
/**
* Implements hook_field_attach_form().
*/
function {{ machine_name }}_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {
// Add a checkbox allowing a given field to be emptied.
// See hook_field_attach_submit() for the corresponding processing code.
$form['empty_field_foo'] = array(
'#type' => 'checkbox',
'#title' => t("Empty the 'field_foo' field"),
);
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_field_attach_insert().
*/
function {{ machine_name }}_field_attach_insert($entity_type, $entity) {
// @todo Needs function body.
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_field_attach_load().
*/
function {{ machine_name }}_field_attach_load($entity_type, $entities, $age, $options) {
// @todo Needs function body.
}

View file

@ -0,0 +1,8 @@
/**
* Implements hook_field_attach_prepare_translation_alter().
*/
function {{ machine_name }}_field_attach_prepare_translation_alter(&$entity, $context) {
if ($context['entity_type'] == 'custom_entity_type') {
$entity->custom_field = $context['source_entity']->custom_field;
}
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_field_attach_preprocess_alter().
*/
function {{ machine_name }}_field_attach_preprocess_alter(&$variables, $context) {
// @todo Needs function body.
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_field_attach_presave().
*/
function {{ machine_name }}_field_attach_presave($entity_type, $entity) {
// @todo Needs function body.
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_field_attach_purge().
*/
function {{ machine_name }}_field_attach_purge($entity_type, $entity, $field, $instance) {
// find the corresponding data in mymodule and purge it
if ($entity_type == 'node' && $field->field_name == 'my_field_name') {
mymodule_remove_mydata($entity->nid);
}
}

View file

@ -0,0 +1,14 @@
/**
* Implements hook_field_attach_rename_bundle().
*/
function {{ machine_name }}_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) {
// Update the extra weights variable with new information.
if ($bundle_old !== $bundle_new) {
$extra_weights = variable_get('field_extra_weights', array());
if (isset($info[$entity_type][$bundle_old])) {
$extra_weights[$entity_type][$bundle_new] = $extra_weights[$entity_type][$bundle_old];
unset($extra_weights[$entity_type][$bundle_old]);
variable_set('field_extra_weights', $extra_weights);
}
}
}

View file

@ -0,0 +1,11 @@
/**
* Implements hook_field_attach_submit().
*/
function {{ machine_name }}_field_attach_submit($entity_type, $entity, $form, &$form_state) {
// Sample case of an 'Empty the field' checkbox added on the form, allowing
// a given field to be emptied.
$values = drupal_array_get_nested_value($form_state['values'], $form['#parents']);
if (!empty($values['empty_field_foo'])) {
unset($entity->field_foo);
}
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_field_attach_update().
*/
function {{ machine_name }}_field_attach_update($entity_type, $entity) {
// @todo Needs function body.
}

View file

@ -0,0 +1,18 @@
/**
* Implements hook_field_attach_validate().
*/
function {{ machine_name }}_field_attach_validate($entity_type, $entity, &$errors) {
// Make sure any images in article nodes have an alt text.
if ($entity_type == 'node' && $entity->type == 'article' && !empty($entity->field_image)) {
foreach ($entity->field_image as $langcode => $items) {
foreach ($items as $delta => $item) {
if (!empty($item['fid']) && empty($item['alt'])) {
$errors['field_image'][$langcode][$delta][] = array(
'error' => 'field_example_invalid',
'message' => t('All images in articles need to have an alternative text set.'),
);
}
}
}
}
}

View file

@ -0,0 +1,20 @@
/**
* Implements hook_field_attach_view_alter().
*/
function {{ machine_name }}_field_attach_view_alter(&$output, $context) {
// Append RDF term mappings on displayed taxonomy links.
foreach (element_children($output) as $field_name) {
$element = &$output[$field_name];
if ($element['#field_type'] == 'taxonomy_term_reference' && $element['#formatter'] == 'taxonomy_term_reference_link') {
foreach ($element['#items'] as $delta => $item) {
$term = $item['taxonomy_term'];
if (!empty($term->rdf_mapping['rdftype'])) {
$element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype'];
}
if (!empty($term->rdf_mapping['name']['predicates'])) {
$element[$delta]['#options']['attributes']['property'] = $term->rdf_mapping['name']['predicates'];
}
}
}
}
}

View file

@ -0,0 +1,11 @@
/**
* Implements hook_field_available_languages_alter().
*/
function {{ machine_name }}_field_available_languages_alter(&$languages, $context) {
// Add an unavailable language.
$languages[] = 'xx';
// Remove an available language.
$index = array_search('yy', $languages);
unset($languages[$index]);
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_field_create_field().
*/
function {{ machine_name }}_field_create_field($field) {
// @todo Needs function body.
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_field_create_instance().
*/
function {{ machine_name }}_field_create_instance($instance) {
// @todo Needs function body.
}

View file

@ -0,0 +1,15 @@
/**
* Implements hook_field_delete().
*/
function {{ machine_name }}_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
foreach ($items as $delta => $item) {
// For hook_file_references(), remember that this is being deleted.
$item['file_field_name'] = $field['field_name'];
// Pass in the ID of the object that is being removed so all references can
// be counted in hook_file_references().
$item['file_field_type'] = $entity_type;
$item['file_field_id'] = $id;
file_field_delete_file($item, $field, $entity_type, $id);
}
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_field_delete_field().
*/
function {{ machine_name }}_field_delete_field($field) {
// @todo Needs function body.
}

View file

@ -0,0 +1,6 @@
/**
* Implements hook_field_delete_instance().
*/
function {{ machine_name }}_field_delete_instance($instance) {
// @todo Needs function body.
}

View file

@ -0,0 +1,13 @@
/**
* Implements hook_field_delete_revision().
*/
function {{ machine_name }}_field_delete_revision($entity_type, $entity, $field, $instance, $langcode, &$items) {
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
foreach ($items as $delta => $item) {
// For hook_file_references, remember that this file is being deleted.
$item['file_field_name'] = $field['field_name'];
if (file_field_delete_file($item, $field, $entity_type, $id)) {
$items[$delta] = NULL;
}
}
}

View file

@ -0,0 +1,9 @@
/**
* Implements hook_field_display_ENTITY_TYPE_alter().
*/
function {{ machine_name }}_field_display_ENTITY_TYPE_alter(&$display, $context) {
// Leave field labels out of the search index.
if ($context['view_mode'] == 'search_index') {
$display['label'] = 'hidden';
}
}

View file

@ -0,0 +1,13 @@
/**
* Implements hook_field_display_alter().
*/
function {{ machine_name }}_field_display_alter(&$display, $context) {
// Leave field labels out of the search index.
// Note: The check against $context['entity_type'] == 'node' could be avoided
// by using hook_field_display_node_alter() instead of
// hook_field_display_alter(), resulting in less function calls when
// rendering non-node entities.
if ($context['entity_type'] == 'node' && $context['view_mode'] == 'search_index') {
$display['label'] = 'hidden';
}
}

Some files were not shown because too many files have changed in this diff Show more