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


PHP TypedDataManager::createListDataDefinition方法代码示例

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


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

示例1: testFields

 /**
  * Tests deriving metadata about fields.
  */
 public function testFields()
 {
     $field_definition = BaseFieldDefinition::create('integer');
     // Fields are lists of complex data.
     $this->assertTrue($field_definition instanceof ListDataDefinitionInterface);
     $this->assertFalse($field_definition instanceof ComplexDataDefinitionInterface);
     $field_item_definition = $field_definition->getItemDefinition();
     $this->assertFalse($field_item_definition instanceof ListDataDefinitionInterface);
     $this->assertTrue($field_item_definition instanceof ComplexDataDefinitionInterface);
     // Derive metadata about field item properties.
     $this->assertEqual(array_keys($field_item_definition->getPropertyDefinitions()), array('value'));
     $this->assertEqual($field_item_definition->getPropertyDefinition('value')->getDataType(), 'integer');
     $this->assertEqual($field_item_definition->getMainPropertyName(), 'value');
     $this->assertNull($field_item_definition->getPropertyDefinition('invalid'));
     // Test accessing field item property metadata via the field definition.
     $this->assertTrue($field_definition instanceof FieldDefinitionInterface);
     $this->assertEqual(array_keys($field_definition->getPropertyDefinitions()), array('value'));
     $this->assertEqual($field_definition->getPropertyDefinition('value')->getDataType(), 'integer');
     $this->assertEqual($field_definition->getMainPropertyName(), 'value');
     $this->assertNull($field_definition->getPropertyDefinition('invalid'));
     // Test using the definition factory for field item lists and field items.
     $field_item = $this->typedDataManager->createDataDefinition('field_item:integer');
     $this->assertFalse($field_item instanceof ListDataDefinitionInterface);
     $this->assertTrue($field_item instanceof ComplexDataDefinitionInterface);
     // Comparison should ignore the internal static cache, so compare the
     // serialized objects instead.
     $this->assertEqual(serialize($field_item_definition), serialize($field_item));
     $field_definition2 = $this->typedDataManager->createListDataDefinition('field_item:integer');
     $this->assertTrue($field_definition2 instanceof ListDataDefinitionInterface);
     $this->assertFalse($field_definition2 instanceof ComplexDataDefinitionInterface);
     $this->assertEqual(serialize($field_definition), serialize($field_definition2));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:35,代码来源:EntityTypedDataDefinitionTest.php

示例2: testLists

 /**
  * Tests deriving metadata about list items.
  */
 public function testLists()
 {
     $list_definition = ListDataDefinition::create('string');
     $this->assertTrue($list_definition instanceof ListDataDefinitionInterface);
     $item_definition = $list_definition->getItemDefinition();
     $this->assertTrue($item_definition instanceof DataDefinitionInterface);
     $this->assertEqual($item_definition->getDataType(), 'string');
     // Test using the definition factory.
     $list_definition2 = $this->typedDataManager->createListDataDefinition('string');
     $this->assertTrue($list_definition2 instanceof ListDataDefinitionInterface);
     $this->assertEqual($list_definition, $list_definition2);
     // Test creating the definition of data with type 'list', which is the same
     // as creating a definition of a list of items of type 'any'.
     $list_definition = $this->typedDataManager->createDataDefinition('list');
     $this->assertTrue($list_definition instanceof ListDataDefinitionInterface);
     $this->assertEqual($list_definition->getDataType(), 'list');
     $this->assertEqual($list_definition->getItemDefinition()->getDataType(), 'any');
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:21,代码来源:TypedDataDefinitionTest.php


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