You are here

public static function WorkableItem::baseFieldDefinitions in Drupal PM (Project Management) 4.x

Returns an array of base field definitions for publishing status.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type to add the publishing status field to.

Return value

\Drupal\Core\Field\BaseFieldDefinition[] An array of base field definitions.

Throws

\Drupal\Core\Entity\Exception\UnsupportedEntityTypeDefinitionException Thrown when the entity type does not implement EntityPublishedInterface or if it does not have a "published" entity key.

Overrides ContentEntityBase::baseFieldDefinitions

4 calls to WorkableItem::baseFieldDefinitions()
Epic::baseFieldDefinitions in modules/pm_epic/src/Entity/Epic.php
Returns an array of base field definitions for publishing status.
Feature::baseFieldDefinitions in modules/pm_feature/src/Entity/Feature.php
Returns an array of base field definitions for publishing status.
SubTask::baseFieldDefinitions in modules/pm_sub_task/src/Entity/SubTask.php
Returns an array of base field definitions for publishing status.
WorkableItemWithRevision::baseFieldDefinitions in modules/pm_project/src/Entity/WorkableItemWithRevision.php
Returns an array of base field definitions for publishing status.
4 methods override WorkableItem::baseFieldDefinitions()
Epic::baseFieldDefinitions in modules/pm_epic/src/Entity/Epic.php
Returns an array of base field definitions for publishing status.
Feature::baseFieldDefinitions in modules/pm_feature/src/Entity/Feature.php
Returns an array of base field definitions for publishing status.
SubTask::baseFieldDefinitions in modules/pm_sub_task/src/Entity/SubTask.php
Returns an array of base field definitions for publishing status.
WorkableItemWithRevision::baseFieldDefinitions in modules/pm_project/src/Entity/WorkableItemWithRevision.php
Returns an array of base field definitions for publishing status.

File

modules/pm_project/src/Entity/WorkableItem.php, line 43

Class

WorkableItem
Provides Workable Item.

Namespace

Drupal\pm_project\Entity

Code

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
  $fields = parent::baseFieldDefinitions($entity_type);
  $fields['uid'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Authored by'))
    ->setDescription(t('The user ID of author of the Issue entity.'))
    ->setRevisionable(TRUE)
    ->setSetting('target_type', 'user')
    ->setSetting('handler', 'default')
    ->setDisplayOptions('view', [
    'label' => 'hidden',
    'type' => 'author',
    'weight' => 0,
  ])
    ->setDisplayOptions('form', [
    'type' => 'entity_reference_autocomplete',
    'weight' => 5,
    'settings' => [
      'match_operator' => 'CONTAINS',
      'size' => '60',
      'autocomplete_type' => 'tags',
      'placeholder' => '',
    ],
  ])
    ->setDisplayConfigurable('form', TRUE)
    ->setDisplayConfigurable('view', TRUE);
  $fields['label'] = BaseFieldDefinition::create('string')
    ->setLabel(t('Label'))
    ->setRevisionable(TRUE)
    ->setSettings([
    'max_length' => 255,
    'text_processing' => 0,
  ])
    ->setDefaultValue('')
    ->setDisplayOptions('view', [
    'label' => 'above',
    'type' => 'string',
    'weight' => -4,
  ])
    ->setDisplayOptions('form', [
    'type' => 'string_textfield',
    'weight' => -4,
  ])
    ->setDisplayConfigurable('form', TRUE)
    ->setDisplayConfigurable('view', TRUE)
    ->setRequired(TRUE);
  $fields['project'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(new TranslatableMarkup('Project'))
    ->setSetting('target_type', 'pm_project')
    ->setSetting('handler', 'default')
    ->setDisplayOptions('view', [
    'label' => 'hidden',
    'type' => 'Project',
    'weight' => 0,
  ])
    ->setDisplayOptions('form', [
    'type' => 'entity_reference_autocomplete',
    'weight' => 5,
    'settings' => [
      'match_operator' => 'CONTAINS',
      'size' => '60',
      'autocomplete_type' => 'tags',
      'placeholder' => '',
    ],
  ])
    ->setDisplayConfigurable('form', TRUE)
    ->setDisplayConfigurable('view', TRUE)
    ->setRequired(TRUE)
    ->setCardinality(1);
  $fields['created'] = BaseFieldDefinition::create('created')
    ->setLabel(t('Created'))
    ->setDescription(t('The time that the entity was created.'));
  $fields['changed'] = BaseFieldDefinition::create('changed')
    ->setLabel(t('Changed'))
    ->setDescription(t('The time that the entity was last edited.'));
  return $fields;
}