本文整理汇总了PHP中Drupal\entity_test\Entity\EntityTest::baseFieldDefinitions方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityTest::baseFieldDefinitions方法的具体用法?PHP EntityTest::baseFieldDefinitions怎么用?PHP EntityTest::baseFieldDefinitions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\entity_test\Entity\EntityTest
的用法示例。
在下文中一共展示了EntityTest::baseFieldDefinitions方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['custom_langcode_key'] = $fields['langcode'];
unset($fields['langcode']);
return $fields;
}
示例2: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['name']->setDisplayOptions('form', array('type' => 'string', 'weight' => 0));
$fields['name']->addConstraint('FieldWidgetConstraint', array());
return $fields;
}
示例3: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['name']->setDisplayOptions('form', array('type' => 'string', 'weight' => 0));
$fields['type']->setDisplayOptions('form', array('type' => 'entity_reference_autocomplete', 'weight' => 0));
return $fields;
}
示例4: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['test_no_display'] = BaseFieldDefinition::create('text')->setLabel(t('Field with no display'));
$fields['test_display_configurable'] = BaseFieldDefinition::create('text')->setLabel(t('Field with configurable display'))->setDisplayOptions('view', array('type' => 'text_default', 'weight' => 10))->setDisplayConfigurable('view', TRUE)->setDisplayOptions('form', array('type' => 'text_textfield', 'weight' => 10))->setDisplayConfigurable('form', TRUE);
$fields['test_display_non_configurable'] = BaseFieldDefinition::create('text')->setLabel(t('Field with non-configurable display'))->setDisplayOptions('view', array('type' => 'text_default', 'weight' => 11))->setDisplayOptions('form', array('type' => 'text_textfield', 'weight' => 11));
return $fields;
}
示例5: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['test_no_display'] = BaseFieldDefinition::create('text')->setLabel(t('Field with no display'));
$fields['test_display_configurable'] = BaseFieldDefinition::create('text')->setLabel(t('Field with configurable display'))->setDisplayOptions('view', array('type' => 'text_default', 'weight' => 10))->setDisplayConfigurable('view', TRUE)->setDisplayOptions('form', array('type' => 'text_textfield', 'weight' => 10))->setDisplayConfigurable('form', TRUE);
$fields['test_display_non_configurable'] = BaseFieldDefinition::create('text')->setLabel(t('Field with non-configurable display'))->setDisplayOptions('view', array('type' => 'text_default', 'weight' => 11))->setDisplayOptions('form', array('type' => 'text_textfield', 'weight' => 11));
$fields['test_display_multiple'] = BaseFieldDefinition::create('text')->setLabel(t('A field with multiple values'))->setCardinality(FieldStorageDefinition::CARDINALITY_UNLIMITED)->setDisplayOptions('view', array('type' => 'text_default', 'weight' => 12))->setDisplayOptions('form', array('type' => 'text_textfield', 'weight' => 12));
return $fields;
}
示例6: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['revision_id'] = FieldDefinition::create('integer')->setLabel(t('Revision ID'))->setDescription(t('The version id of the test entity.'))->setReadOnly(TRUE)->setSetting('unsigned', TRUE);
$fields['langcode']->setRevisionable(TRUE);
$fields['name']->setRevisionable(TRUE);
$fields['user_id']->setRevisionable(TRUE);
return $fields;
}
示例7: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['revision_id'] = BaseFieldDefinition::create('integer')->setLabel(t('Revision ID'))->setDescription(t('The version id of the test entity.'))->setReadOnly(TRUE)->setSetting('unsigned', TRUE);
$fields['langcode']->setRevisionable(TRUE);
$fields['name']->setRevisionable(TRUE);
$fields['user_id']->setRevisionable(TRUE);
$fields['non_rev_field'] = BaseFieldDefinition::create('string')->setLabel(t('Non Revisionable Field'))->setDescription(t('A non-revisionable test field.'))->setRevisionable(FALSE)->setTranslatable(TRUE)->setCardinality(1)->setReadOnly(TRUE);
return $fields;
}
示例8: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['id'] = BaseFieldDefinition::create('string')->setLabel(t('ID'))->setDescription(t('The ID of the test entity.'))->setReadOnly(TRUE)->setSetting('is_ascii', TRUE);
return $fields;
}
示例9: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'));
return $fields;
}
示例10: testBaseTableFields
/**
* Tests fields on the base table.
*/
public function testBaseTableFields()
{
$base_field_definitions = $this->setupBaseFields(EntityTest::baseFieldDefinitions($this->baseEntityType));
$user_base_field_definitions = ['uid' => BaseFieldDefinition::create('integer')->setLabel('ID')->setDescription('The ID of the user entity.')->setReadOnly(TRUE)->setSetting('unsigned', TRUE)];
$this->entityManager->expects($this->any())->method('getBaseFieldDefinitions')->will($this->returnValueMap([['user', $user_base_field_definitions], ['entity_test', $base_field_definitions]]));
// Setup the table mapping.
$table_mapping = $this->getMock('Drupal\\Core\\Entity\\Sql\\TableMappingInterface');
$table_mapping->expects($this->any())->method('getTableNames')->willReturn(['entity_test']);
$table_mapping->expects($this->any())->method('getColumnNames')->willReturnMap([['id', ['value' => 'id']], ['uuid', ['value' => 'uuid']], ['type', ['value' => 'type']], ['langcode', ['value' => 'langcode']], ['name', ['value' => 'name']], ['description', ['value' => 'description__value', 'format' => 'description__format']], ['homepage', ['value' => 'homepage']], ['user_id', ['target_id' => 'user_id']]]);
$table_mapping->expects($this->any())->method('getFieldNames')->willReturnMap([['entity_test', ['id', 'uuid', 'type', 'langcode', 'name', 'description', 'homepage', 'user_id']]]);
$this->entityStorage->expects($this->once())->method('getTableMapping')->willReturn($table_mapping);
$this->setupFieldStorageDefinition();
$data = $this->viewsData->getViewsData();
$this->assertNumericField($data['entity_test']['id']);
$this->assertField($data['entity_test']['id'], 'id');
$this->assertUuidField($data['entity_test']['uuid']);
$this->assertField($data['entity_test']['uuid'], 'uuid');
$this->assertStringField($data['entity_test']['type']);
$this->assertEquals('type', $data['entity_test']['type']['entity field']);
$this->assertLanguageField($data['entity_test']['langcode']);
$this->assertField($data['entity_test']['langcode'], 'langcode');
$this->assertEquals('Original language', $data['entity_test']['langcode']['title']);
$this->assertStringField($data['entity_test']['name']);
$this->assertField($data['entity_test']['name'], 'name');
$this->assertLongTextField($data['entity_test'], 'description');
$this->assertField($data['entity_test']['description__value'], 'description');
$this->assertField($data['entity_test']['description__format'], 'description');
$this->assertUriField($data['entity_test']['homepage']);
$this->assertField($data['entity_test']['homepage'], 'homepage');
$this->assertEntityReferenceField($data['entity_test']['user_id']);
$this->assertField($data['entity_test']['user_id'], 'user_id');
$relationship = $data['entity_test']['user_id']['relationship'];
$this->assertEquals('users_field_data', $relationship['base']);
$this->assertEquals('uid', $relationship['base field']);
}
示例11: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['description'] = BaseFieldDefinition::create('shape')->setLabel(t('Some custom description'))->setDefaultValueCallback('entity_test_field_default_value');
return $fields;
}
示例12: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['name']->setDescription('The default description.');
return $fields;
}
示例13: testBaseTableFields
/**
* Tests fields on the base table.
*/
public function testBaseTableFields()
{
$base_field_definitions = $this->setupBaseFields(EntityTest::baseFieldDefinitions($this->baseEntityType));
$user_base_field_definitions = ['uid' => BaseFieldDefinition::create('integer')->setLabel('ID')->setDescription('The ID of the user entity.')->setReadOnly(TRUE)->setSetting('unsigned', TRUE)];
$this->entityManager->expects($this->any())->method('getBaseFieldDefinitions')->will($this->returnValueMap([['user', $user_base_field_definitions], ['entity_test', $base_field_definitions]]));
// Setup the table mapping.
$table_mapping = $this->getMockBuilder(DefaultTableMapping::class)->disableOriginalConstructor()->getMock();
$table_mapping->expects($this->any())->method('getTableNames')->willReturn(['entity_test', 'entity_test__string']);
$table_mapping->expects($this->any())->method('getColumnNames')->willReturnMap([['id', ['value' => 'id']], ['uuid', ['value' => 'uuid']], ['type', ['value' => 'type']], ['langcode', ['value' => 'langcode']], ['name', ['value' => 'name']], ['description', ['value' => 'description__value', 'format' => 'description__format']], ['homepage', ['value' => 'homepage']], ['user_id', ['target_id' => 'user_id']], ['string', ['value' => 'value']]]);
$table_mapping->expects($this->any())->method('getFieldNames')->willReturnMap([['entity_test', ['id', 'uuid', 'type', 'langcode', 'name', 'description', 'homepage', 'user_id']], ['entity_test__string', ['string']]]);
$table_mapping->expects($this->any())->method('requiresDedicatedTableStorage')->willReturnCallback(function (BaseFieldDefinition $base_field) {
return $base_field->getName() === 'string';
});
$table_mapping->expects($this->any())->method('getDedicatedDataTableName')->willReturnCallback(function (BaseFieldDefinition $base_field) {
if ($base_field->getName() === 'string') {
return 'entity_test__string';
}
});
$this->entityStorage->expects($this->once())->method('getTableMapping')->willReturn($table_mapping);
$this->setupFieldStorageDefinition();
$data = $this->viewsData->getViewsData();
$this->assertNumericField($data['entity_test']['id']);
$this->assertField($data['entity_test']['id'], 'id');
$this->assertUuidField($data['entity_test']['uuid']);
$this->assertField($data['entity_test']['uuid'], 'uuid');
$this->assertStringField($data['entity_test']['type']);
$this->assertEquals('type', $data['entity_test']['type']['entity field']);
$this->assertLanguageField($data['entity_test']['langcode']);
$this->assertField($data['entity_test']['langcode'], 'langcode');
$this->assertEquals('Original language', $data['entity_test']['langcode']['title']);
$this->assertStringField($data['entity_test']['name']);
$this->assertField($data['entity_test']['name'], 'name');
$this->assertLongTextField($data['entity_test'], 'description');
$this->assertField($data['entity_test']['description__value'], 'description');
$this->assertField($data['entity_test']['description__format'], 'description');
$this->assertUriField($data['entity_test']['homepage']);
$this->assertField($data['entity_test']['homepage'], 'homepage');
$this->assertEntityReferenceField($data['entity_test']['user_id']);
$this->assertField($data['entity_test']['user_id'], 'user_id');
$relationship = $data['entity_test']['user_id']['relationship'];
$this->assertEquals('users_field_data', $relationship['base']);
$this->assertEquals('uid', $relationship['base field']);
$this->assertStringField($data['entity_test__string']['string']);
$this->assertField($data['entity_test__string']['string'], 'string');
$this->assertEquals(['left_field' => 'id', 'field' => 'entity_id', 'extra' => [['field' => 'deleted', 'value' => 0, 'numeric' => TRUE]]], $data['entity_test__string']['table']['join']['entity_test']);
}
示例14: baseFieldDefinitions
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
{
$fields = parent::baseFieldDefinitions($entity_type);
$fields['name']->setCardinality(2);
return $fields;
}