function apigee_api_catalog_node_update in Apigee API Catalog 8.2
Implements hook_ENTITY_TYPE_update().
1 call to apigee_api_catalog_node_update()
- apigee_api_catalog_node_insert in ./
apigee_api_catalog.module - Implements hook_ENTITY_TYPE_insert().
File
- ./
apigee_api_catalog.module, line 130 - Copyright 2019 Google Inc.
Code
function apigee_api_catalog_node_update(EntityInterface $entity) {
if ($entity
->bundle() == 'apidoc') {
$systemPath = '/node/' . $entity
->id();
$langCode = $entity
->language()
->getId();
$exists = \Drupal::service('path_alias.manager')
->getAliasByPath($systemPath, $langCode);
if ($exists == $systemPath) {
\Drupal::entityTypeManager()
->getStorage('path_alias')
->create([
'path' => $systemPath,
'alias' => '/api/' . $entity
->id(),
'langcode' => $langCode,
])
->save();
}
}
}