當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。