You are here

public function Term::summary in Term condition 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Condition/Term.php \Drupal\term_condition\Plugin\Condition\Term::summary()

Provides a human readable summary of the condition's configuration.

Overrides ConditionInterface::summary

File

src/Plugin/Condition/Term.php, line 195
Contains \Drupal\term_condition\Plugin\Condition\Term.

Class

Term
Provides a 'Term' condition to enable a condition based in module selected status.

Namespace

Drupal\term_condition\Plugin\Condition

Code

public function summary() {
  $terms = [];
  $term_ids = $this->configuration['tid'];
  foreach ($term_ids as $term_id) {
    $terms[] = $this->entityTypeManager
      ->getStorage('taxonomy_term')
      ->load(array_pop($term_id))
      ->getName();
  }
  $term_list = implode(", ", $terms);
  if (!empty($this->configuration['negate'])) {
    return $this
      ->t('The node is not associated with taxonomy term(s) @term_list.', array(
      '@term_list' => $term_list,
    ));
  }
  else {
    return $this
      ->t('The node is associated with taxonomy term(s) @term_list.', array(
      '@term_list' => $term_list,
    ));
  }
}