function PathHooks::entityBaseFieldInfo

Implements hook_entity_base_field_info().

Attributes

#[Hook('entity_base_field_info')]

File

core/modules/path/src/Hook/PathHooks.php, line 106

Class

PathHooks
Hook implementations for path.

Namespace

Drupal\path\Hook

Code

public function entityBaseFieldInfo(EntityTypeInterface $entity_type) : array {
  if (in_array($entity_type->id(), [
    'taxonomy_term',
    'node',
    'media',
  ], TRUE)) {
    $fields['path'] = BaseFieldDefinition::create('path')->setLabel($this->t('URL alias'))
      ->setTranslatable(TRUE)
      ->setDisplayOptions('form', [
      'type' => 'path',
      'weight' => 30,
    ])
      ->setDisplayConfigurable('form', TRUE)
      ->setComputed(TRUE);
    return $fields;
  }
  return [];
}

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