protected function AlinkPostRenderer::getKeywords in Alinks 8
Load alinks keywords.
Return value
\Drupal\alinks\Entity\Keyword[] Returns a list of all of the alinks keywords.
2 calls to AlinkPostRenderer::getKeywords()
- AlinkPostRenderer::processDomNodeList in src/
AlinkPostRenderer.php - Process the node list to replace links.
- AlinkPostRenderer::replace in src/
AlinkPostRenderer.php - Load the content and replace the matched strings with automatic links.
File
- src/
AlinkPostRenderer.php, line 68
Class
- AlinkPostRenderer
- Class AlinkPostRenderer.
Namespace
Drupal\alinksCode
protected function getKeywords() {
if ($this->keywords === NULL) {
$ids = \Drupal::entityQuery('alink_keyword')
->condition('status', 1)
->execute();
$this->keywords = Keyword::loadMultiple($ids);
$vocabularies = \Drupal::config('alinks.settings')
->get('vocabularies');
if ($vocabularies) {
$terms = \Drupal::entityQuery('taxonomy_term')
->condition('vid', $vocabularies, 'IN')
->execute();
$terms = Term::loadMultiple($terms);
foreach ($terms as $term) {
$this->keywords[] = Keyword::create([
'name' => $term
->label(),
'link' => [
'uri' => 'internal:/' . $term
->toUrl()
->getInternalPath(),
],
]);
}
}
foreach ($this->keywords as &$keyword) {
$keyword->stemmed_keyword = $this->stemmer
->stem($keyword
->getText());
}
}
return $this->keywords;
}