You are here

static function SelectedFilters::getTermIdFromUrlAlias in Taxonomy Facets 8

Get term id.

For a given taxonomy term name return the term id. @todo deal with duplicate term names, i.e same name in 2 vocabularies.

Return value

integer Return the term id. return null if no term with this name found.

1 call to SelectedFilters::getTermIdFromUrlAlias()
SelectedFilters::__construct in src/SelectedFilters.php

File

src/SelectedFilters.php, line 60

Class

SelectedFilters

Namespace

Drupal\taxonomy_facets

Code

static function getTermIdFromUrlAlias($term_alias) {
  $select = db_select('url_alias', 'u');

  // Select these specific fields for the output.
  $select
    ->addField('u', 'source');

  // Filter only persons named "John".
  $select
    ->condition('u.alias', '/' . $term_alias);
  $entries = $select
    ->execute()
    ->fetchAll(\PDO::FETCH_ASSOC);
  if (!empty($entries)) {
    $entries = explode('/', current(current($entries)));
    return $entries[3];
  }
  else {
    return NULL;
  }
}