You are here

protected function YamlForm::updatePath in YAML Form 8

Saves a path alias to the database.

Parameters

string $source: The internal system path.

string $alias: The URL alias.

string $langcode: (optional) The language code of the alias.

1 call to YamlForm::updatePath()
YamlForm::updatePaths in src/Entity/YamlForm.php
Update submit and confirm paths (ie URL aliases) associated with this form.

File

src/Entity/YamlForm.php, line 1255

Class

YamlForm
Defines the form entity.

Namespace

Drupal\yamlform\Entity

Code

protected function updatePath($source, $alias, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED) {

  /** @var \Drupal\Core\Path\AliasStorageInterface $path_alias_storage */
  $path_alias_storage = \Drupal::service('path.alias_storage');
  $path = $path_alias_storage
    ->load([
    'source' => $source,
    'langcode' => $langcode,
  ]);

  // Check if the path alias is already setup.
  if ($path && $path['alias'] == $alias) {
    return;
  }
  $path_alias_storage
    ->save($source, $alias, $langcode, $path['pid']);
}