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


PHP VocabularyInterface::set方法代碼示例

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


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

示例1: testTaxonomyTermFieldChangeMachineName

 /**
  * Tests that vocabulary machine name changes are mirrored in field definitions.
  */
 function testTaxonomyTermFieldChangeMachineName()
 {
     // Add several entries in the 'allowed_values' setting, to make sure that
     // they all get updated.
     $this->fieldStorage->setSetting('allowed_values', [array('vocabulary' => $this->vocabulary->id(), 'parent' => '0'), array('vocabulary' => $this->vocabulary->id(), 'parent' => '0'), array('vocabulary' => 'foo', 'parent' => '0')]);
     $this->fieldStorage->save();
     // Change the machine name.
     $new_name = Unicode::strtolower($this->randomMachineName());
     $this->vocabulary->set('vid', $new_name);
     $this->vocabulary->save();
     // Check that the field is still attached to the vocabulary.
     $field_storage = FieldStorageConfig::loadByName('entity_test', $this->fieldName);
     $allowed_values = $field_storage->getSetting('allowed_values');
     $this->assertEqual($allowed_values[0]['vocabulary'], $new_name, 'Index 0: Machine name was updated correctly.');
     $this->assertEqual($allowed_values[1]['vocabulary'], $new_name, 'Index 1: Machine name was updated correctly.');
     $this->assertEqual($allowed_values[2]['vocabulary'], 'foo', 'Index 2: Machine name was left untouched.');
 }
開發者ID:Nikola-xiii,項目名稱:d8intranet,代碼行數:20,代碼來源:TermFieldTest.php


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