当前位置: 首页>>代码示例>>PHP>>正文


PHP VocabularyInterface::uuid方法代码示例

本文整理汇总了PHP中Drupal\taxonomy\VocabularyInterface::uuid方法的典型用法代码示例。如果您正苦于以下问题:PHP VocabularyInterface::uuid方法的具体用法?PHP VocabularyInterface::uuid怎么用?PHP VocabularyInterface::uuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\taxonomy\VocabularyInterface的用法示例。


在下文中一共展示了VocabularyInterface::uuid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testConfigEntityReferenceItem

 /**
  * Tests the entity reference field type for referencing config entities.
  */
 public function testConfigEntityReferenceItem()
 {
     $referenced_entity_id = $this->vocabulary->id();
     // Just being able to create the entity like this verifies a lot of code.
     $entity = EntityTest::create();
     $entity->field_test_taxonomy_vocabulary->target_id = $referenced_entity_id;
     $entity->name->value = $this->randomMachineName();
     $entity->save();
     $entity = entity_load('entity_test', $entity->id());
     $this->assertTrue($entity->field_test_taxonomy_vocabulary instanceof FieldItemListInterface, 'Field implements interface.');
     $this->assertTrue($entity->field_test_taxonomy_vocabulary[0] instanceof FieldItemInterface, 'Field item implements interface.');
     $this->assertEqual($entity->field_test_taxonomy_vocabulary->target_id, $referenced_entity_id);
     $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->label(), $this->vocabulary->label());
     $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->id(), $referenced_entity_id);
     $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->uuid(), $this->vocabulary->uuid());
     // Change the name of the term via the reference.
     $new_name = $this->randomMachineName();
     $entity->field_test_taxonomy_vocabulary->entity->set('name', $new_name);
     $entity->field_test_taxonomy_vocabulary->entity->save();
     // Verify it is the correct name.
     $vocabulary = Vocabulary::load($referenced_entity_id);
     $this->assertEqual($vocabulary->label(), $new_name);
     // Make sure the computed term reflects updates to the term id.
     $vocabulary2 = $vocabulary = Vocabulary::create(['name' => $this->randomMachineName(), 'vid' => Unicode::strtolower($this->randomMachineName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]);
     $vocabulary2->save();
     $entity->field_test_taxonomy_vocabulary->target_id = $vocabulary2->id();
     $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->id(), $vocabulary2->id());
     $this->assertEqual($entity->field_test_taxonomy_vocabulary->entity->label(), $vocabulary2->label());
     // Delete terms so we have nothing to reference and try again
     $this->vocabulary->delete();
     $vocabulary2->delete();
     $entity = EntityTest::create(array('name' => $this->randomMachineName()));
     $entity->save();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:37,代码来源:EntityReferenceItemTest.php


注:本文中的Drupal\taxonomy\VocabularyInterface::uuid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。