You are here

public static function SubTask::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 WorkableItem::baseFieldDefinitions

File

modules/pm_sub_task/src/Entity/SubTask.php, line 64

Class

SubTask
Defines the Sub task entity.

Namespace

Drupal\pm_sub_task\Entity

Code

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
  $fields = parent::baseFieldDefinitions($entity_type);
  $fields['pm_issue'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Parent'))
    ->setDescription('')
    ->setSetting('target_type', 'pm_issue')
    ->setSetting('handler', 'default')
    ->setDisplayOptions('view', [
    'label' => 'hidden',
    'type' => 'Issue',
    '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);
  return $fields;
}