本文整理匯總了PHP中Drupal\Core\TypedData\TypedDataManager::createInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP TypedDataManager::createInstance方法的具體用法?PHP TypedDataManager::createInstance怎麽用?PHP TypedDataManager::createInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\TypedData\TypedDataManager
的用法示例。
在下文中一共展示了TypedDataManager::createInstance方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createInstance
/**
* {@inheritdoc}
*/
public function createInstance($data_type, array $configuration = array())
{
$instance = parent::createInstance($data_type, $configuration);
// Enable elements to construct their own definitions using the typed config
// manager.
if ($instance instanceof ArrayElement) {
$instance->setTypedConfig($this);
}
return $instance;
}
示例2: createInstance
/**
* {@inheritdoc}
*
* Creates a field item, which is not part of an entity or field item list.
*
* @param string $field_type
* The field type, for which a field item should be created.
* @param array $configuration
* The plugin configuration array, i.e. an array with the following keys:
* - field_definition: The field definition object, i.e. an instance of
* Drupal\Core\Field\FieldDefinitionInterface.
*
* @return \Drupal\Core\Field\FieldItemInterface
* The instantiated object.
*/
public function createInstance($field_type, array $configuration = array())
{
$configuration['data_definition'] = $configuration['field_definition']->getItemDefinition();
return $this->typedDataManager->createInstance("field_item:{$field_type}", $configuration);
}