當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Term::id方法代碼示例

本文整理匯總了PHP中Drupal\taxonomy\Entity\Term::id方法的典型用法代碼示例。如果您正苦於以下問題:PHP Term::id方法的具體用法?PHP Term::id怎麽用?PHP Term::id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\taxonomy\Entity\Term的用法示例。


在下文中一共展示了Term::id方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUpNode

 /**
  * Creates a test subject node, with translation.
  */
 protected function setUpNode()
 {
     /** @var \Drupal\node\Entity\Node $node */
     $node = entity_create('node', array('title' => $this->randomMachineName(), 'type' => 'article', 'description' => array('value' => $this->randomMachineName(), 'format' => 'basic_html'), $this->termFieldName => array(array('target_id' => $this->term->id())), 'langcode' => $this->baseLangcode));
     $node->save();
     $node->addTranslation($this->translateToLangcode, $node->toArray());
     $node->save();
     $this->node = $node;
 }
開發者ID:nsp15,項目名稱:Drupal8,代碼行數:12,代碼來源:TermTranslationFieldViewTest.php

示例2: buildTermListItem

 /**
  * Builds an individual term item for the term item list depending on the formatter.
  *
  * @param \Drupal\taxonomy\Entity\Term $term
  * @return string
  */
 private function buildTermListItem(Term $term, $formatter)
 {
     if ($formatter === 'linked') {
         $link_url = Url::fromRoute('entity.taxonomy_term.canonical', array('taxonomy_term' => $term->id()));
         return \Drupal::l($term->label(), $link_url);
     }
     return HTML::escape($term->label());
 }
開發者ID:freefree12,項目名稱:d8-demo-modules,代碼行數:14,代碼來源:VocabularyTerms.php

示例3: setUp

 public function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('taxonomy_term');
     $vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $vocabulary->save();
     entity_create('field_storage_config', array('name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, 'settings' => array('allowed_values' => array(array('vocabulary' => $vocabulary->id(), 'parent' => 0)))))->save();
     entity_create('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => $this->fieldName, 'bundle' => 'entity_test'))->save();
     $this->term = entity_create('taxonomy_term', array('name' => $this->randomName(), 'vid' => $vocabulary->id(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED));
     $this->term->save();
     // Add the mapping.
     $mapping = rdf_get_mapping('entity_test', 'entity_test');
     $mapping->setFieldMapping($this->fieldName, array('properties' => array('schema:about')))->save();
     // Set up test values.
     $this->entity = entity_create('entity_test');
     $this->entity->{$this->fieldName}->target_id = $this->term->id();
     $this->entity->save();
     $this->uri = $this->getAbsoluteUri($this->entity);
 }
開發者ID:alnutile,項目名稱:drunatra,代碼行數:19,代碼來源:TaxonomyTermReferenceRdfaTest.php

示例4: getCid

 public static function getCid(Node $benzinarie, Term $tip_carburant)
 {
     return 'benzinarie:' . $benzinarie->id() . ':carburant:' . $tip_carburant->id();
 }
開發者ID:hacktm15,項目名稱:lapompa,代碼行數:4,代碼來源:PretCarburant.php


注:本文中的Drupal\taxonomy\Entity\Term::id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。