You are here

public function PowerMenuTaxonomyHandler::getMenuPathToActivate in Power Menu 7.2

Overrides PowerMenuHandlerInterface::getMenuPathToActivate

See also

PowerMenuHandlerInterface::getMenuPathToActivate()

File

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

Class

PowerMenuTaxonomyHandler
Implementation of the interface PowerMenuHandlerInterface.

Code

public function getMenuPathToActivate($entity, $type, array $router_item, $alias) {
  $path = NULL;
  $mlid = NULL;
  $terms = variable_get('power_menu_taxonomy_terms', array());
  $entity_terms = PowerMenuTaxonomyHandler::getTaxonomyTermsFromEntity($entity, $type);

  // Search a mlid for a entity term
  foreach ($entity_terms as $value) {
    if (array_key_exists($value['tid'], $terms)) {
      $mlid = $terms[$value['tid']];
    }
  }
  if ($mlid != NULL) {
    $menu_link = menu_link_load($mlid);
    if ($menu_link) {
      $path = $menu_link['link_path'];
    }
  }
  return $path;
}