本文整理汇总了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.');
}