예제 #1
0
 public function preRender(&$values)
 {
     $vocabularies = $this->vocabularyStorage->loadMultiple();
     $this->field_alias = $this->aliases['nid'];
     $nids = array();
     foreach ($values as $result) {
         if (!empty($result->{$this->aliases['nid']})) {
             $nids[] = $result->{$this->aliases['nid']};
         }
     }
     if ($nids) {
         $vocabs = array_filter($this->options['vids']);
         if (empty($this->options['limit'])) {
             $vocabs = array();
         }
         $result = \Drupal::entityManager()->getStorage('taxonomy_term')->getNodeTerms($nids, $vocabs);
         foreach ($result as $node_nid => $data) {
             foreach ($data as $tid => $term) {
                 $this->items[$node_nid][$tid]['name'] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
                 $this->items[$node_nid][$tid]['tid'] = $tid;
                 $this->items[$node_nid][$tid]['vocabulary_vid'] = $term->getVocabularyId();
                 $this->items[$node_nid][$tid]['vocabulary'] = $vocabularies[$term->getVocabularyId()]->label();
                 if (!empty($this->options['link_to_taxonomy'])) {
                     $this->items[$node_nid][$tid]['make_link'] = TRUE;
                     $this->items[$node_nid][$tid]['path'] = 'taxonomy/term/' . $tid;
                 }
             }
         }
     }
 }
예제 #2
0
파일: Tid.php 프로젝트: nsp15/Drupal8
 /**
  * {@inheritdoc}
  */
 public function calculateDependencies()
 {
     $dependencies = parent::calculateDependencies();
     foreach ($this->vocabularyStorage->loadMultiple(array_keys($this->options['vids'])) as $vocabulary) {
         $dependencies[$vocabulary->getConfigDependencyKey()][] = $vocabulary->getConfigDependencyName();
     }
     return $dependencies;
 }
예제 #3
0
 /**
  * Determines if the vocabulary already exists.
  *
  * @param string $vid
  *   The vocabulary ID.
  *
  * @return bool
  *   TRUE if the vocabulary exists, FALSE otherwise.
  */
 public function exists($vid)
 {
     $action = $this->vocabularyStorage->load($vid);
     return !empty($action);
 }