public function YamlForm::updatePaths in YAML Form 8
Update submit and confirm paths (ie URL aliases) associated with this form.
Overrides YamlFormInterface::updatePaths
1 call to YamlForm::updatePaths()
- YamlForm::postSave in src/
Entity/ YamlForm.php - Acts on a saved entity before the insert or update hook is invoked.
File
- src/
Entity/ YamlForm.php, line 1207
Class
- YamlForm
- Defines the form entity.
Namespace
Drupal\yamlform\EntityCode
public function updatePaths() {
// Path module must be enable for URL aliases to be updated.
if (!\Drupal::moduleHandler()
->moduleExists('path')) {
return;
}
// Update submit path.
$submit_path = $this->settings['page_submit_path'] ?: trim(\Drupal::config('yamlform.settings')
->get('settings.default_page_base_path'), '/') . '/' . str_replace('_', '-', $this
->id());
$submit_source = '/yamlform/' . $this
->id();
$submit_alias = '/' . trim($submit_path, '/');
$this
->updatePath($submit_source, $submit_alias, $this->langcode);
$this
->updatePath($submit_source, $submit_alias, LanguageInterface::LANGCODE_NOT_SPECIFIED);
// Update confirm path.
$confirm_path = $this->settings['page_confirm_path'] ?: $submit_path . '/confirmation';
$confirm_source = '/yamlform/' . $this
->id() . '/confirmation';
$confirm_alias = '/' . trim($confirm_path, '/');
$this
->updatePath($confirm_source, $confirm_alias, $this->langcode);
$this
->updatePath($confirm_source, $confirm_alias, LanguageInterface::LANGCODE_NOT_SPECIFIED);
// Update submissions path.
$submissions_path = $submit_path . '/submissions';
$submissions_source = '/yamlform/' . $this
->id() . '/submissions';
$submissions_alias = '/' . trim($submissions_path, '/');
$this
->updatePath($submissions_source, $submissions_alias, $this->langcode);
$this
->updatePath($submissions_source, $submissions_alias, LanguageInterface::LANGCODE_NOT_SPECIFIED);
}