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


PHP VocabularyInterface::get方法代碼示例

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


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

示例1: testTermIndentation

 /**
  * Tests term indentation.
  */
 function testTermIndentation()
 {
     // Create three taxonomy terms.
     $term1 = $this->createTerm($this->vocabulary);
     $term2 = $this->createTerm($this->vocabulary);
     $term3 = $this->createTerm($this->vocabulary);
     // Get the taxonomy storage.
     $taxonomy_storage = $this->container->get('entity.manager')->getStorage('taxonomy_term');
     // Indent the second term under the first one.
     $edit = array('terms[tid:' . $term2->id() . ':0][term][tid]' => 2, 'terms[tid:' . $term2->id() . ':0][term][parent]' => 1, 'terms[tid:' . $term2->id() . ':0][term][depth]' => 1, 'terms[tid:' . $term2->id() . ':0][weight]' => 1);
     // Submit the edited form and check for HTML indentation element presence.
     $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid') . '/overview', $edit, t('Save'));
     $this->assertPattern('|<div class="js-indentation indentation">&nbsp;</div>|');
     // Check explicitly that term 2's parent is term 1.
     $parents = $taxonomy_storage->loadParents($term2->id());
     $this->assertEqual(key($parents), 1, 'Term 1 is the term 2\'s parent');
     // Move the second term back out to the root level.
     $edit = array('terms[tid:' . $term2->id() . ':0][term][tid]' => 2, 'terms[tid:' . $term2->id() . ':0][term][parent]' => 0, 'terms[tid:' . $term2->id() . ':0][term][depth]' => 0, 'terms[tid:' . $term2->id() . ':0][weight]' => 1);
     $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid') . '/overview', $edit, t('Save'));
     // All terms back at the root level, no indentation should be present.
     $this->assertNoPattern('|<div class="js-indentation indentation">&nbsp;</div>|');
     // Check explicitly that term 2 has no parents.
     \Drupal::entityManager()->getStorage('taxonomy_term')->resetCache();
     $parents = $taxonomy_storage->loadParents($term2->id());
     $this->assertTrue(empty($parents), 'Term 2 has no parents now');
 }
開發者ID:neetumorwani,項目名稱:blogging,代碼行數:29,代碼來源:TaxonomyTermIndentationTest.php


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