W3cubDocs

/Drupal 8

public static function RevisionLogEntityTrait::revisionLogBaseFieldDefinitions

public static RevisionLogEntityTrait::revisionLogBaseFieldDefinitions(EntityTypeInterface $entity_type)

Provides revision-related base field definitions for an entity type.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type definition.

Return value

\Drupal\Core\Field\FieldDefinitionInterface[] An array of base field definitions for the entity type, keyed by field name.

See also

\Drupal\Core\Entity\FieldableEntityInterface::baseFieldDefinitions()

File

core/lib/Drupal/Core/Entity/RevisionLogEntityTrait.php, line 27

Class

RevisionLogEntityTrait
Provides a trait for accessing revision logging and ownership information.

Namespace

Drupal\Core\Entity

Code

public static function revisionLogBaseFieldDefinitions(EntityTypeInterface $entity_type) {
  $fields['revision_created'] = BaseFieldDefinition::create('created')
    ->setLabel(t('Revision create time'))
    ->setDescription(t('The time that the current revision was created.'))
    ->setRevisionable(TRUE);

  $fields['revision_user'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Revision user'))
    ->setDescription(t('The user ID of the author of the current revision.'))
    ->setSetting('target_type', 'user')
    ->setRevisionable(TRUE);

  $fields['revision_log_message'] = BaseFieldDefinition::create('string_long')
    ->setLabel(t('Revision log message'))
    ->setDescription(t('Briefly describe the changes you have made.'))
    ->setRevisionable(TRUE)
    ->setDefaultValue('')
    ->setDisplayOptions('form', [
      'type' => 'string_textarea',
      'weight' => 25,
      'settings' => [
        'rows' => 4,
      ],
    ]);

  return $fields;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!RevisionLogEntityTrait.php/function/RevisionLogEntityTrait::revisionLogBaseFieldDefinitions/8.1.x