You are here

function redirect_field_extra_fields in Redirect 7

Same name and namespace in other branches
  1. 7.2 redirect.module \redirect_field_extra_fields()

Implements hook_field_extra_fields().

File

./redirect.module, line 1705

Code

function redirect_field_extra_fields() {
  $entity_info = entity_get_info();
  $info = array();
  foreach (array_keys($entity_info) as $entity_type) {
    if (!redirect_entity_type_supports_redirects($entity_type)) {

      // Redirect is explicitly disabled for this entity type.
      continue;
    }
    if (!empty($entity_info[$entity_type]['bundles'])) {
      foreach (array_keys($entity_info[$entity_type]['bundles']) as $bundle) {
        if (!isset($entity_info[$entity_type]['bundles'][$bundle]['uri callback']) && !isset($entity_info[$entity_type]['uri callback'])) {

          // The bundle or base entity must have an URI callback defined otherwise
          // we cannot use the entity_uri() function to lookup the entity's source
          // path.
          continue;
        }
        $info[$entity_type][$bundle]['form']['redirect'] = array(
          'label' => t('URL redirects'),
          'description' => t('Redirect module form elements'),
          'weight' => 30,
        );
      }
    }
  }
  return $info;
}