本文整理匯總了PHP中Drupal\Core\Field\FieldStorageDefinitionInterface::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP FieldStorageDefinitionInterface::save方法的具體用法?PHP FieldStorageDefinitionInterface::save怎麽用?PHP FieldStorageDefinitionInterface::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Field\FieldStorageDefinitionInterface
的用法示例。
在下文中一共展示了FieldStorageDefinitionInterface::save方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE)
{
parent::setUp();
$field_name = 'test_options';
$this->fieldStorage = FieldStorageConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'list_string', 'cardinality' => 1, 'settings' => ['allowed_values_function' => 'options_test_dynamic_values_callback']]);
$this->fieldStorage->save();
$this->field = FieldConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'required' => TRUE])->save();
}
示例2: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
parent::setUp();
$field_name = 'test_options';
$this->fieldStorage = entity_create('field_storage_config', ['field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'list_string', 'cardinality' => 1, 'settings' => ['allowed_values_function' => 'options_test_dynamic_values_callback']]);
$this->fieldStorage->save();
$this->field = entity_create('field_config', ['field_name' => $field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'required' => TRUE])->save();
}
示例3: setUp
protected function setUp()
{
parent::setUp();
$field_name = 'test_options';
$this->fieldStorage = FieldStorageConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test_rev', 'type' => 'list_string', 'cardinality' => 1, 'settings' => ['allowed_values_function' => 'options_test_dynamic_values_callback']]);
$this->fieldStorage->save();
$this->field = FieldConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev', 'required' => TRUE])->save();
entity_get_form_display('entity_test_rev', 'entity_test_rev', 'default')->setComponent($field_name, ['type' => 'options_select'])->save();
// Create an entity and prepare test data that will be used by
// options_test_dynamic_values_callback().
$values = ['user_id' => mt_rand(1, 10), 'name' => $this->randomMachineName()];
$this->entity = EntityTestRev::create($values);
$this->entity->save();
$this->test = ['label' => $this->entity->label(), 'uuid' => $this->entity->uuid(), 'bundle' => $this->entity->bundle(), 'uri' => $this->entity->url()];
}