Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PathHooks.php

function PathHooks::entityBaseFieldInfo

Implements hook_entity_base_field_info().

File

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

Class

PathHooks
Hook implementations for path.

Namespace

Drupal\path\Hook

Code

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal