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


PHP User::getEntityTypeId方法代码示例

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


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

示例1: testSerialize

 /**
  * Test registered Serializer's entity serialization for core's formats.
  */
 public function testSerialize()
 {
     // Test that Serializer responds using the ComplexDataNormalizer and
     // JsonEncoder. The output of ComplexDataNormalizer::normalize() is tested
     // elsewhere, so we can just assume that it works properly here.
     $normalized = $this->serializer->normalize($this->entity, 'json');
     $expected = json_encode($normalized);
     // Test 'json'.
     $actual = $this->serializer->serialize($this->entity, 'json');
     $this->assertIdentical($actual, $expected, 'Entity serializes to JSON when "json" is requested.');
     $actual = $this->serializer->serialize($normalized, 'json');
     $this->assertIdentical($actual, $expected, 'A normalized array serializes to JSON when "json" is requested');
     // Test 'ajax'.
     $actual = $this->serializer->serialize($this->entity, 'ajax');
     $this->assertIdentical($actual, $expected, 'Entity serializes to JSON when "ajax" is requested.');
     $actual = $this->serializer->serialize($normalized, 'ajax');
     $this->assertIdentical($actual, $expected, 'A normalized array serializes to JSON when "ajax" is requested');
     // Generate the expected xml in a way that allows changes to entity property
     // order.
     $expected = array('id' => '<id><value>' . $this->entity->id() . '</value></id>', 'uuid' => '<uuid><value>' . $this->entity->uuid() . '</value></uuid>', 'langcode' => '<langcode><value>en</value></langcode>', 'name' => '<name><value>' . $this->values['name'] . '</value></name>', 'type' => '<type><value>entity_test_mulrev</value></type>', 'created' => '<created><value>' . $this->entity->created->value . '</value></created>', 'user_id' => '<user_id><target_id>' . $this->user->id() . '</target_id><target_type>' . $this->user->getEntityTypeId() . '</target_type><target_uuid>' . $this->user->uuid() . '</target_uuid><url>' . $this->user->url() . '</url></user_id>', 'revision_id' => '<revision_id><value>' . $this->entity->getRevisionId() . '</value></revision_id>', 'default_langcode' => '<default_langcode><value>1</value></default_langcode>', 'non_rev_field' => '<non_rev_field/>', 'field_test_text' => '<field_test_text><value>' . $this->values['field_test_text']['value'] . '</value><format>' . $this->values['field_test_text']['format'] . '</format></field_test_text>');
     // Sort it in the same order as normalised.
     $expected = array_merge($normalized, $expected);
     // Add header and footer.
     array_unshift($expected, '<?xml version="1.0"?>' . PHP_EOL . '<response>');
     $expected[] = '</response>' . PHP_EOL;
     // Reduced the array to a string.
     $expected = implode('', $expected);
     // Test 'xml'. The output should match that of Symfony's XmlEncoder.
     $actual = $this->serializer->serialize($this->entity, 'xml');
     $this->assertIdentical($actual, $expected);
     $actual = $this->serializer->serialize($normalized, 'xml');
     $this->assertIdentical($actual, $expected);
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:36,代码来源:EntitySerializationTest.php


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