EntityTestWithRevisionLog.php

Same filename and directory in other branches
  1. 9 core/modules/system/tests/modules/entity_test_revlog/src/Entity/EntityTestWithRevisionLog.php
  2. 8.9.x core/modules/system/tests/modules/entity_test_revlog/src/Entity/EntityTestWithRevisionLog.php
  3. 10 core/modules/system/tests/modules/entity_test_revlog/src/Entity/EntityTestWithRevisionLog.php

Namespace

Drupal\entity_test_revlog\Entity

File

core/modules/system/tests/modules/entity_test_revlog/src/Entity/EntityTestWithRevisionLog.php

View source
<?php

declare (strict_types=1);
namespace Drupal\entity_test_revlog\Entity;

use Drupal\Core\Entity\Attribute\ContentEntityType;
use Drupal\Core\Entity\Routing\RevisionHtmlRouteProvider;
use Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider;
use Drupal\Core\Entity\Form\RevisionRevertForm;
use Drupal\Core\Entity\Form\RevisionDeleteForm;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\RevisionableContentEntityBase;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\entity_test_revlog\EntityTestRevlogAccessControlHandler;

/**
 * Defines the test entity class.
 */
class EntityTestWithRevisionLog extends RevisionableContentEntityBase {
  
  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['name'] = BaseFieldDefinition::create('string')->setLabel(t('Name'))
      ->setDescription(t('The name of the test entity.'))
      ->setRevisionable(TRUE)
      ->setSetting('max_length', 64)
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'string',
      'weight' => -5,
    ])
      ->setDisplayOptions('form', [
      'type' => 'string_textfield',
      'weight' => -5,
    ]);
    return $fields;
  }
  
  /**
   * Sets the name.
   *
   * @param string $name
   *   Name of the entity.
   *
   * @return $this
   */
  public function setName(string $name) {
    $this->set('name', $name);
    return $this;
  }

}

Classes

Title Deprecated Summary
EntityTestWithRevisionLog Defines the test entity class.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.