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


PHP TypedDataManager::createDataDefinition方法代码示例

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


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

示例1: testDataReferences

 /**
  * Tests deriving metadata from data references.
  */
 public function testDataReferences()
 {
     $language_reference_definition = DataReferenceDefinition::create('language');
     $this->assertTrue($language_reference_definition instanceof DataReferenceDefinitionInterface);
     // Test retrieving metadata about the referenced data.
     $this->assertEqual($language_reference_definition->getTargetDefinition()->getDataType(), 'language');
     // Test using the definition factory.
     $language_reference_definition2 = $this->typedDataManager->createDataDefinition('language_reference');
     $this->assertTrue($language_reference_definition2 instanceof DataReferenceDefinitionInterface);
     $this->assertEqual($language_reference_definition, $language_reference_definition2);
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:14,代码来源:TypedDataDefinitionTest.php

示例2: testGetContextValuesContext

 /**
  * @covers ::getContextValues
  */
 public function testGetContextValuesContext()
 {
     $data_definition = DataDefinition::createFromDataType('integer');
     $typed_data = IntegerData::createInstance($data_definition);
     $this->typedDataManager->createDataDefinition('integer')->willReturn($data_definition);
     $this->typedDataManager->getDefaultConstraints($data_definition)->willReturn([]);
     $this->typedDataManager->create($data_definition, 5)->willReturn($typed_data);
     $input = ['foo' => ['label' => 'Foo', 'type' => 'integer', 'value' => 5]];
     $expected = new Context(new ContextDefinition('integer', 'Foo'), 5);
     $actual = $this->staticContext->getContextValues($input)['foo'];
     $this->assertEquals($expected, $actual);
 }
开发者ID:ns-oxit-study,项目名称:drupal-8-training,代码行数:15,代码来源:ContextMapperTest.php

示例3: getTypedData

 /**
  * Returns a typed data object.
  *
  * This helper for quick creation of typed data objects.
  *
  * @param string $data_type
  *   The data type to create an object for.
  * @param mixed[] $value
  *   The value to set.
  *
  * @return \Drupal\Core\TypedData\TypedDataInterface
  *   The created object.
  */
 protected function getTypedData($data_type, $value)
 {
     $definition = $this->typedDataManager->createDataDefinition($data_type);
     $data = $this->typedDataManager->create($definition);
     $data->setValue($value);
     return $data;
 }
开发者ID:shahinam,项目名称:drupal8devel,代码行数:20,代码来源:RulesIntegrationTestBase.php

示例4: testEntityReferences

 /**
  * Tests deriving metadata from entity references.
  */
 public function testEntityReferences()
 {
     $reference_definition = DataReferenceDefinition::create('entity');
     $this->assertTrue($reference_definition instanceof DataReferenceDefinitionInterface);
     // Test retrieving metadata about the referenced data.
     $this->assertEqual($reference_definition->getTargetDefinition()->getDataType(), 'entity');
     $this->assertTrue($reference_definition->getTargetDefinition() instanceof EntityDataDefinitionInterface);
     // Test that the definition factory creates the right definition object.
     $reference_definition2 = $this->typedDataManager->createDataDefinition('entity_reference');
     $this->assertTrue($reference_definition2 instanceof DataReferenceDefinitionInterface);
     $this->assertEqual($reference_definition2, $reference_definition);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:15,代码来源:EntityTypedDataDefinitionTest.php


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