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

Breadcrumb

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

function PathHooks::entityTranslationCreate

Implements hook_entity_translation_create().

File

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

Class

PathHooks
Hook implementations for path.

Namespace

Drupal\path\Hook

Code

public function entityTranslationCreate(ContentEntityInterface $translation) {
    foreach ($translation->getFieldDefinitions() as $field_name => $field_definition) {
        if ($field_definition->getType() === 'path' && $translation->get($field_name)->pid) {
            // If there are values and a path ID, update the langcode and unset the
            // path ID to save this as a new alias.
            $translation->get($field_name)->langcode = $translation->language()
                ->getId();
            $translation->get($field_name)->pid = NULL;
        }
    }
}

API Navigation

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