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


PHP EntityTest::baseFieldDefinitions方法代码示例

本文整理汇总了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;
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:10,代码来源:EntityTestMulLangcodeKey.php

示例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;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:EntityTestConstraintViolation.php

示例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;
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:10,代码来源:EntityTestCompositeConstraint.php

示例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;
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:11,代码来源:EntityTestBaseFieldDisplay.php

示例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;
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:12,代码来源:EntityTestBaseFieldDisplay.php

示例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;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:12,代码来源:EntityTestRev.php

示例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;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:13,代码来源:EntityTestRev.php

示例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;
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:9,代码来源:EntityTestStringId.php

示例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;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:9,代码来源:EntityTestConstraints.php

示例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']);
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:38,代码来源:EntityViewsDataTest.php

示例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;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:9,代码来源:EntityTestDefaultValue.php

示例12: baseFieldDefinitions

 /**
  * {@inheritdoc}
  */
 public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
 {
     $fields = parent::baseFieldDefinitions($entity_type);
     $fields['name']->setDescription('The default description.');
     return $fields;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:9,代码来源:EntityTestFieldOverride.php

示例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']);
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:49,代码来源:EntityViewsDataTest.php

示例14: baseFieldDefinitions

 /**
  * {@inheritdoc}
  */
 public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
 {
     $fields = parent::baseFieldDefinitions($entity_type);
     $fields['name']->setCardinality(2);
     return $fields;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:9,代码来源:EntityTestMultiValueBasefield.php


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