You are here

public static function PowerMenuTaxonomyHandler::getTaxonomyFieldsFromEntity in Power Menu 7.2

Returns all fields with a taxonomy reference to the selected menu taxonomy vocabulary.

Parameters

$type: Return only fields for this entity type

Return value

An array of field definitions

1 call to PowerMenuTaxonomyHandler::getTaxonomyFieldsFromEntity()
PowerMenuTaxonomyHandler::getTaxonomyTermsFromEntity in plugins/menu_handlers/PowerMenuTaxonomyHandler.class.php
Returns an array of taxonomy terms associated with tis entity.

File

plugins/menu_handlers/PowerMenuTaxonomyHandler.class.php, line 281

Class

PowerMenuTaxonomyHandler
Implementation of the interface PowerMenuHandlerInterface.

Code

public static function getTaxonomyFieldsFromEntity($type = FALSE) {
  $vocabulary = variable_get('power_menu_taxonomy_vocabulary', array(
    'vid' => NULL,
    'machine_name' => NULL,
  ));
  $fileds = field_info_fields();

  // Remove not taxonomy related fields and taxonomy fields that belongs to other vocabularies or entity types
  foreach ($fileds as $field_name => $value) {
    if ($value['type'] != 'taxonomy_term_reference' || $value['settings']['allowed_values'][0]['vocabulary'] != $vocabulary['machine_name'] || $type && empty($value['bundles'][$type])) {
      unset($fileds[$field_name]);
    }
  }
  return $fileds;
}