You are here

public static function ExpireAPI::expireTermPages in Cache Expiration 7.2

Find all taxonomy terms in the entity fields and build urls for them.

Parameters

$entity: Entity object.

$entity_type: Type of entity.

Return value

array Term urls that should be flushed.

4 calls to ExpireAPI::expireTermPages()
ExpireComment::expire in includes/expire.comment.inc
Executes expiration actions for comment.
ExpireNode::expire in includes/expire.node.inc
Executes expiration actions for node.
ExpireTaxonomyTerm::expire in includes/expire.taxonomy_term.inc
Executes expiration actions for taxonomy term.
ExpireUser::expire in includes/expire.user.inc
Executes expiration actions for user.

File

includes/expire.api.inc, line 185
Provides internal API for page cache flushes.

Class

ExpireAPI
@file Provides internal API for page cache flushes.

Code

public static function expireTermPages($entity, $entity_type) {
  $terms = array();
  list($id, $vid, $bundle_name) = entity_extract_ids($entity_type, $entity);
  $field_instances = field_info_instances($entity_type, $bundle_name);
  foreach ($field_instances as $field_name => $field_instance) {

    // Load information about field.
    $field_info = field_info_field($field_name);
    if ($field_info['type'] == 'taxonomy_term_reference') {
      $new_terms = field_get_items($entity_type, $entity, $field_name);
      if (is_array($new_terms) && !empty($new_terms)) {
        $terms = array_merge($new_terms, $terms);
      }
      $old_terms = !empty($entity->original) ? field_get_items($entity_type, $entity->original, $field_name) : array();
      if (is_array($old_terms) && !empty($old_terms)) {
        $terms = array_merge($old_terms, $terms);
      }
    }
  }
  $urls = array();
  foreach ($terms as $term) {
    $urls['term-' . $term['tid']] = 'taxonomy/term/' . $term['tid'];
  }
  return $urls;
}