You are here

function commerce_store_update_8201 in Commerce Core 8.2

Add the URL alias path field to stores.

File

modules/store/commerce_store.install, line 14
Contains install and update functions for commerce_store module.

Code

function commerce_store_update_8201() {
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  if (!\Drupal::moduleHandler()
    ->moduleExists('path')) {
    \Drupal::service('module_installer')
      ->install([
      'path',
    ]);
  }
  $storage_definition = BaseFieldDefinition::create('path')
    ->setLabel(t('URL alias'))
    ->setDescription(t('The store URL alias.'))
    ->setTranslatable(TRUE)
    ->setDisplayOptions('form', [
    'type' => 'path',
    'weight' => 30,
  ])
    ->setDisplayConfigurable('form', TRUE)
    ->setCustomStorage(TRUE);
  $definition_update_manager
    ->installFieldStorageDefinition('path', 'commerce_store', 'commerce_store', $storage_definition);
}